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

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Szymon N. (Guest)
on 2006-04-07 13:42
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: http://siter.com.au/dmitry/images.html.
Alex Y. (Guest)
on 2006-04-07 14: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.
Mikkel B. (Guest)
on 2006-04-07 14: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 Y. wrote:
>> Something like this: http://siter.com.au/dmitry/images.html.
>Rails mailing list
>removed_email_address@domain.invalid
>http://lists.rubyonrails.org/mailman/listinfo/rails


Mikkel B.

www.strongside.dk    - Football Portal(DK)
ting.minline.dk      - Buy Old Stuff!(DK)
Szymon N. (Guest)
on 2006-04-07 18:44
Thanks, i didn't know that img handles onload event.
This topic is locked and can not be replied to.