On Nov 12, 2009, at 6:10 AM, Michel Belleville wrote:

You may also like this nifty little trick :
$('#myImage').attr('src', 'image.jpg').load(function() { alert('Image Loaded'); });

Apparently images does use the .load() event callback.

Michel Belleville


Good point, Michel. You have to be careful, though, because IE won't report cached images as loaded that way. Instead you need to check the image's .complete property. You might also want to handle images that don't load properly. Someone (can't remember who) recently pointed me to an article that discusses the complexities involved and provides a function:
http://lucassmith.name/2008/11/is-my-image-loaded.html
(beware the first helper function)

Cheers,

--Karl

____________
Karl Swedberg
www.englishrules.com
www.learningjquery.com

Reply via email to