Javascript examples for DOM Event:Element Event Attribute
The onerror event is triggered if an error occurs while loading an external document or image.
Bubbles | No |
---|---|
Cancelable | No |
Supported HTML tags: | <img>, <input type="image">, <object>, <link>, and <script> <audio> and <video> |
<!DOCTYPE html> <html> <body> <img id="myImg" src="http://java2s.com/resources/a.png"> <p id="demo"></p> <script> document.getElementById("myImg").onerror = function() {myFunction()}; function myFunction() {//w w w . j a va 2 s.c o m document.getElementById("demo").innerHTML = "The image could not be loaded."; } </script> </body> </html>