[thelist] Several javascript issues.
Jon Hughes
hughesj at firemtn.com
Tue Jul 24 12:45:15 CDT 2007
The Code:
window.onload = function()
{
var popinfo =
document.getElementById("content").getElementsByTagName("img");
for (var i=0; i<popinfo.length; i++) {
if (popinfo[i].alt == "Click for more details") {
popinfo[i].onmouseover = function() { var popname =
popinfo[i].title; alert(popname); }
popinfo[i].onmouseout = function() { var popname = popinfo[i].title;
alert(popname); }
}
}
}
This doesn't work. The error in firebug when I mouseover the image is:
"Popinfo[i] has no properties"
Now, if I do this:
window.onload = function()
{
var popinfo =
document.getElementById("content").getElementsByTagName("img");
for (var i=0; i<popinfo.length; i++) {
if (popinfo[i].alt == "Click for more details") {
var popname = popinfo[i].title;
popinfo[i].onmouseover = function() { alert(popname); }
popinfo[i].onmouseout = function() { alert(popname); }
}
}
}
It doesn't give me any errors when I mouseover, but the alert is for the
last popinfo[i] in the array, where I want the one currently being
mouse'd over.
I apologize for not having a test page, I am at work and have no access
to one.
Thank You,
- Jon Hughes
More information about the thelist
mailing list