Edit This Code:
<!DOCTYPE html>
<html>
<head>
<script>
function imgError() {
    alert('The image could not be loaded.');
}
</script>
</head>
<body>

<img src="http://www.w3schools.com/js/image.gif" onerror="imgError()">
<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>

</body>
</html>


Result:
Try it Yourself - © w3schools.com
Privacy Policy