Forum Moderators: open

Message Too Old, No Replies

End of request?

         

ahmedtheking

8:35 pm on May 16, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is it possible to use JS to check when an image has finished loading?

StupidScript

9:51 pm on May 16, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Other than using the "onload" event?

ahmedtheking

11:16 am on May 17, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well how can you apply onload on to an image that's loading? $('imageid').onload?

Drag_Racer

2:18 pm on May 17, 2007 (gmt 0)

10+ Year Member



<img onload="myFunction()">

use myFunction to set a global variable to true, then you can check the variable to see if the image has loaded yet.

Drag_Racer

2:36 pm on May 17, 2007 (gmt 0)

10+ Year Member



I was first going to suggest to check readyState but the img tag is just easier, but here it is anyway...

if(document.getElementById('myImgID').readyState=='complete'){
// image is loaded
}
else {
// image not finished loading
}

<img src="theimage.gif" id="myImgId">

check JS documentation how to implement properly with onReadyStateChange