JavaScript check when image has downloaded?

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

JavaScript check when image has downloaded?

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

image.complete property or the more fancy image.onload event hook.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

image node has a (undocumented?) complete property
Post Reply