HOME HTML CSS JAVASCRIPT SQL PHP JQUERY XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

Image onerror Event

Image Object Reference Image Object

Definition and Usage

The onerror event is triggered if an error occurs when loading an image.

Syntax

onerror="JavaScriptCode"

Parameter Description
JavaScriptCode Required. Specifies a JavaScript to be executed when the event occurs


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The onerror event is supported in all major browsers.


Example

Example

Display an alert box if an error occurs when loading an image:

<img src="image.gif" onerror="alert('The image could not be loaded.')">

Try it yourself »


Image Object Reference Image Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE