How to wait for an image to be loaded?

Hi!

I’m making a simple gallery, which uses simple javascript for changing
‘src’ attrbiute of ‘img’ element.

How to wait for an image to be downloaded completely before trying to
display it and while browser downloads this image display a spinner gif
or ‘please wait’ message etc.?

Something like this: Siter.

szymek wrote:

This should work, but I haven’t had cause to try it… Load the
high-res image into a hidden img tag, whose onload handler swaps the
spinner’s src attribute for its own. Alternatively, if you’ve got
control over the images, you could be polite to your users and use an
interlaced file format. Not as Web2.0, but much, much cleaner.

Place the img tag in a div with a spinner as background???

On Friday, April 07, 2006, at 11:26 AM, Alex Y. wrote:

Something like this: http://siter.com.au/dmitry/images.html.
Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

Mikkel B.

www.strongside.dk - Football Portal(DK)
ting.minline.dk - Buy Old Stuff!(DK)

Thanks, i didn’t know that img handles onload event.