<html>
<body>
<img src="image.html" onerror="myFunction()">
<p>A function is triggered if an error occurs when loading the image. The function shows an alert box with a text.
In this example we refer to an image that does not exist, therefore the onerror event occurs.</p>
<script>
function myFunction() {
alert('The image could not be loaded.');
}
</script>
</body>
<!-- Mirrored from www.w3schools.com/jsref/tryit.asp?filename=tryjsref_onerror by HTTrack Website Copier/3.x [XR&CO'2014], Mon, 27 Jan 2020 03:02:56 GMT -->
</html>