Well,
I've a little trouble that seems unsolvable. It's a stupid question
that born because IE doesn't respect the standard as its usual.
But go to the problem. I create an anchor tag element, set some
properties, but not all works as it should. This is my code.
var anchorTag = document.createElement('a');
anchorTag.appendChild(document.createTextNode(x));
var pathImg = x.replace(' ', '_').replace('è', 'e');
pathImg = "images/" + pathImg + ".jpg";
anchorTag.href = "#";
anchorTag.setAttribute('onclick', 'popImage("' + pathImg + '", "' + x +
'")');
colorSpan.appendChild(anchorTag);
Doing in this way works fine just for Firefox and other browser. IE,
unfortunately, ignore the setAttribute method name.
The only way I've found to let it work on IE and Firefox too is the
line below.
//anchorTag.onclick = function() { "popImage('" + pathImg + "', '" + x
+ "')" }
Unfortunately, since the code above is nested into a for ... next loop
the code above not assign the pathImg value and x value to the content
of the in-line function but just a reference, and this cause an obvious
problem. All elements onclick event call through the popImage function
the same image.
Is there a way to solve this. Where am I doing mistake?
I've tried using the eval() method without results.
Thanks for any help.
Andrew