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

How to change the pic to a "show error" image when loading imagesfailed?

P: n/a
How to change the pic to a "show error" image when loading images failed
- for example, no image file exists?

I tried to add the following statement in the onload event function:

if (!document.images.AImage.complete) { document.images.AImage.src =
"error.gif";); }

However, I found that a lot of images can be successfully loaded will
also be replaced with the "error.gif".

After remove above line, these exist images can be show successfully.
But I want to change the non-exist images src to the error.gif....
Jul 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Nick wrote:
How to change the pic to a "show error" image when loading images failed
- for example, no image file exists?

I tried to add the following statement in the onload event function:

if (!document.images.AImage.complete) { document.images.AImage.src =
"error.gif";); }

However, I found that a lot of images can be successfully loaded will
also be replaced with the "error.gif".

After remove above line, these exist images can be show successfully.
But I want to change the non-exist images src to the error.gif....


use the eventhandler named: onAbort() or onError() or both.

I think onError() it will do just that. :-)

<img src="nonexistant.gif" onError="alert('help me!');">

Regards,
Erwin Moller
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.