[EMAIL PROTECTED] wrote:
The image itself will also have a load event if your creating it
dynamically:
$('<img src="test.jpg" alt="" />').appendTo(document.body).bind("load",
function() { ... });
The caveat, though, is that I'm not sure when/if the event gets fired
if the image is cached.
From the Learning jQuery book draft (be sure to buy it once its out!):
if ($enlargedCover[0].complete) {
animateEnlarge();
} else {
$enlargedCover.load(animateEnlarge);
}
This is a rare instance in which the load event is more useful to us
than jQuery's custom ready event. Since load is triggered on a document,
image, or frame when all of its contents have fully loaded, we can
observe the event to make sure that all of the image has been loaded
into memory. Only then is the handler executed, and the animation performed.
Internet Explorer and Firefox have different interpretations of what to
do if the image is already in the browser cache. In this case, Firefox
will immediately send the load event to JavaScript, but Internet
Explorer will never send the event because no "load" actually occurred.
To compensate for this, we can use the complete property of the image
element. This property is set to true only if the image is fully loaded,
so we test this value first and start the animation if the image is
ready. If the image is not yet complete, then we wait for a load event
to be triggered.
--
Jörn Zaefferer
http://bassistance.de