How to find that, image is loaded or not

  • Thread starter balakrishnan.dinesh
  • Start date
B

balakrishnan.dinesh

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...
 
R

Randy Webb

(e-mail address removed) 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">
 
B

balakrishnan.dinesh

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...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top