Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY CYBERSECURITY DATA SCIENCE
     ❯   

HTML onerror Attribute


Definition and Usage

The error event occurs when an error occurred during the loading of a media file.


Applies to

The onerror attribute is part of the Event Attributes, and can be used on the following elements:

Elements Event
<audio> onerror
<body> onerror
<embed> onerror
<img> onerror
<link> onerror
<object> onerror
<script> onerror
<video> onerror

Examples

Audio Example

Run "myFunction" if an error occurs during loading:

<audio onerror="myFunction()">

Video Example

Run "myFunction" if an error occures during loading:

<video onerror="myFunction()">


Browser Support

The onerror attribute has the following browser support for each element:

Element
audio Yes 9.0 Yes Yes Yes
body Yes Yes Yes Yes Yes
embed Yes Yes Yes Yes Yes
img Yes Yes Yes Yes Yes
object Yes Yes Yes Yes Yes
link Yes Yes Yes Yes Yes
script Yes Yes Yes Yes Yes
video Yes 9.0 Yes Yes Yes