Test whether image loaded correctly with JavaScript
Posted
by johkar
on Stack Overflow
See other posts from Stack Overflow
or by johkar
Published on 2010-04-20T15:25:34Z
Indexed on
2010/04/20
15:33 UTC
Read the original article
Hit count: 354
JavaScript
|javascript-events
I have an image deployed on several application servers (green up arrow: uparrow.gif). I have an application server status page where I list out all the servers and with a corresponding image where the image's source is the uparrow.gif for that server. If the image does not load (server down) I would like to switch to a red down arrow (downarrow.gif). Is there a way to check whether an image loaded or not with straight JavaScript (no JS libraries etc)? I would imagine I would set an interval for it to continue checking if the user were on the page. Thanks.
© Stack Overflow or respective owner