Image container instead of event object in image load event handler
Posted
by
avok00
on Stack Overflow
See other posts from Stack Overflow
or by avok00
Published on 2011-01-11T19:05:28Z
Indexed on
2011/01/11
22:53 UTC
Read the original article
Hit count: 224
I stumbled upon a very strange thing. In FF 3.6 (not tested others yet) I add onload handler to an image like this:
imgRef.addEventListener("load", activateLink, false);
When load event fires, in activateLink(evt) the evt paramater is not an event, but the "a" tag that contains the image. Why is this?
function activateLink(evt) {
// evt turns out to be a refference to <a> tag (HTMLAnchorElement) that contains the image.
// Actually two of them. Both dynamically added with addElement.
}
I remembered another fact that may be relevant. I have multiple images with the same src that all have registered this same event handler activateLink. Could this be the problem?
© Stack Overflow or respective owner