Forum: Ruby on Rails How to wait for an image to be loaded?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
F639e0cdf2fa098b535d6ec766b2aee1?d=identicon&s=25 Szymon Nowak (g0nzo)
on 2006-04-07 11:42

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:
Ad7805c9fcc1f13efc6ed11251a6c4d2?d=identicon&s=25 Alex Young (Guest)
on 2006-04-07 12:28
(Received via mailing list)
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.
5d15c6821f3c3054c04b85471824ba7c?d=identicon&s=25 Mikkel Bruun (Guest)
on 2006-04-07 12:31
(Received via mailing list)
Place the img tag in a div with a spinner as background???

On Friday, April 07, 2006, at 11:26 AM, Alex Young wrote:
>> Something like this:
>Rails mailing list

Mikkel Bruun    - Football Portal(DK)      - Buy Old Stuff!(DK)
F639e0cdf2fa098b535d6ec766b2aee1?d=identicon&s=25 Szymon Nowak (g0nzo)
on 2006-04-07 16:44
Thanks, i didn't know that img handles onload event.
This topic is locked and can not be replied to.