Waiting for an image to load

wxdqz

New Member
Hi everyone,
is there anyway to wait for an image to load? I'm thinking something like this:


var image = document.createElement("IMG");
image.src = "...";
while(!image.complete);


This doesn't work, as the current thread gets locked at the while statement. It seems this thread is also loading the image. Is there anyway to to something like:


while(!image.complete)
{
Thread.sleep(xxx);
}


Or something like this? I need to wait for the image to load, as I need the dimensions.

Thanks on advance,
Nille
 
Back
Top