Page 1 of 1

JavaScript check when image has downloaded?

Posted: Wed Jun 21, 2006 2:17 pm
by Chris Corbyn
I have a script which rotates images in a gallery. It uses AJAX to change the "src" property of a set of images, then replaces them in the markup of the page. The AJAX is irrelevant to my question though (I think).

The problem I'm facing is that I can't physically determine when the images are downloaded and ready to display. I can only tell when I have correctly changed the src property.

Does anybody have a solution to checking if the image has downloaded, or maybe a solution that actually uses AJAX to download the image data rather than just changing the src property because at least then I can use the event onreadystatechange?

Thanks,

d11wtq

Posted: Wed Jun 21, 2006 2:34 pm
by feyd
image.complete property or the more fancy image.onload event hook.

Posted: Wed Jun 21, 2006 2:42 pm
by Chris Corbyn
feyd wrote:image.complete property or the more fancy image.onload event hook.
Wow! Mr Feyd you ARE a legend! :) Thanks you muchly.

Posted: Wed Jun 21, 2006 2:45 pm
by Weirdan
image node has a (undocumented?) complete property