"Radu Ciurlea" <raduciurlea@gmail.com> writes:
[color=blue]
> function adda(obj,txt,action)
> {[/color]
....[color=blue]
> newlnk.setAttribute('onClick',action);[/color]
....[color=blue]
> }[/color]
.....[color=blue]
> adda('choices',vect[i],"updateBox('" + vect[i] + "')");[/color]
[color=blue]
> I inserted an alert() in the code in the updateBox() function, to
> see if it gets called, and it doesn't. So I believe IE doesn't
> properly assign the onClick attribute to the link. Unfortunately
> there is no DOM inspector (like in FF), so all I can do is guess
> what's wrong. IE won't display any errors.[/color]
You are correct. IE doesn't parse updates to DOM attributes for event
handlers.
[color=blue]
> Any ideas? What's wrong with the code? setAttribute() is a standard
> method (W3 says) so it should work.[/color]
You surely set the attribute. It just doesn't update the live part of
the DOM element, only what it considers the source code that lead to it.
[color=blue]
> It sets the 'href' part right, so I can't see why 'onClick' won't
> work.[/color]
Logic? IE? Naaaah!
Anyway, just assign a function:
----
function adda(obj,txt,action)
{
....
obj.onclick = action;
....
}
....
function makeUpdateCall(value) {
return function(){
updateBox(value);
};
}
function makeSuggestions()
{
....
adda('choices', vect[i], makeUpdateCall(vect[i]));
....
---
Good luck.
/L
--
Lasse Reichstein Nielsen -
lrn@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'