onload and complete of images in IE, Firefox and Safari

Firing the onload() event seems to be inconsistent across browsers. I've tried to explore how browsers behave in this respect, as well as how the .complete property changes. Here are my findings:


ONLOAD FIRES COMPLETE
first cached new first cached new
Firefox 3 Y Y Y F T T
Firefox 2 Y Y Y F T T
IE 8 Y Y Y F T T
IE 6 Y Y Y T T T
Opera 9.52 Y Y Y T T T
Safari 3.2.3 Y N Y F T F


where 'first' means the case when first assigning a source to an image via JavaScript, 'cached' means when assigning the same source once again, and 'new' means when assigning a different source to the image. Values in the 'complete' section show the value of the .complete property as checked immediately after assigning the new source, and thus might be unreliable in case the connection is too fast.

Konqueror probably behaves the same way as Safari. The basic problem of registering the completion of image loads is with these two browsers; however, as the table shows, .complete can be used to distinguish between already cached images and images that are to be loaded.

Popular Posts