Javascript DOM onerror Event via HTML Tag attribute

Description

Javascript DOM onerror Event via HTML Tag attribute

View in separate window

<!DOCTYPE html>
<html>
<body>

<p>This example demonstrates how to assign an "onerror" event to an img element.</p>

<img src="wrong.gif" onerror="myFunction()">

<p id="demo"></p>

<script>
function myFunction() {/* www .ja va 2  s  .c o m*/
  document.getElementById("demo").innerHTML = "The image could not be loaded.";
}
</script>

</body>
</html>
Bubbles: No
Cancelable: No
Event type: UiEvent if generated from a user interface, Event otherwise
Supported HTML tags: <img>, <input type="image">, <object>, <link>, and <script>



PreviousNext

Related