Site Navigation

Sunday, November 11, 2007

bug 208 - onload event fires for every frame of an animated GIF

Issue: #208
Affects: IE5, IE5.5, IE6, IE7
Fixed In: IE8

The onload event can be attached to a window, frame or image element and will fire when the element has fully loaded. However in IE, if you attach this event to an animaged GIF image, it will fire for EVERY frame in the animation!


<img src="waiting.gif" onload="waitLoaded();"/>

If you load this in IE, with an animated GIF, it will continuously execute the waitLoaded() event handler until the user presses Escape/Stop.

Known Workarounds: One.
The only workaround for this, is to immediately nullify the event handler after it has fired the first time.

Example Workaround Code:

<img src="waiting.gif" onload="waitLoaded();this.onload=null;"/>

Related Issues: None.