By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,636 Members | 1,181 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,636 IT Pros & Developers. It's quick & easy.

How to find that, image is loaded or not

P: n/a
hi frnds,
In my senario, My webpage will load dynamically from the
server, Sometimes Images in my is not loading, how can i find , whether
my image is loaded or not, through javascript.

then the image tag will have the id as "imageId"

I have putted alert as document.getElementById('imageId').
eventhough the image is not loaded ,the alert showing it is a object.

Can anyone tell me. how i will be indicated when image not
loaded through a javascript alert.

Rgrds
Dinesh...

Sep 5 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
ba*****************@gmail.com said the following on 9/5/2006 12:55 AM:
hi frnds,
In my senario, My webpage will load dynamically from the
server, Sometimes Images in my is not loading, how can i find , whether
my image is loaded or not, through javascript.

then the image tag will have the id as "imageId"

I have putted alert as document.getElementById('imageId').
eventhough the image is not loaded ,the alert showing it is a object.

Can anyone tell me. how i will be indicated when image not
loaded through a javascript alert.
Use the onload attribute of the img, along with the onerror event handler:

<img onload="alert('It is loaded')"
onerror="alert('There was a problem')"
src="myImage.png">

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Sep 5 '06 #2

P: n/a
Hi Randy,

Thanks for your suggestion, Here there is another problem
when i implemented your idea .

You ask me to put onerror event in image tag. what i did is,
i have keep on refresh the page till the image loaded properly in
onerror event. And i have many request on this same page , While
refreshing the page all requests are repeatedly going again and again
to the server.

Is there anyother way to give request only for the image .
Because i want the image to be loaded ,at the same time other request
should go to server.

Rgrds..
Dinesh...

Sep 22 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.