Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Image onerror Event

Image onerror Event

Image Object Reference Image Object


Definition and Usage

The onerror event is triggered when an error occurs during the loading of a document or image.

Syntax

onerror="

JavaScriptCode

"

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

Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the onerror event


Example

Example

In this example, if an error occurs while loading the image, a dialog box is displayed:

Try it »


Image Object Reference Image Object