Horje

Example of HTML onerror Event Attribute

It will alert that an error occured while loading the video.
index.html
Example: HTML
<!DOCTYPE html>
<html>

<head>
    <title>onerror event attribute</title>
    <style>
        body {
            text-align: center;
        }

        h1 {
            color: green;
        }
    </style>
</head>

<body>
    <img src=
"https://horje.com/avatar.png" 
         onerror="myFunction()">
    <h1>Horje</h1>
    <h2>onerror event attribute</h2>
    <script>
        function myFunction() {
            console.log("The image could not be loaded")
        }
    </script>
</body>

</html

Output should be:

Example of HTML onerror Event Attribute




Type:
html
Category:
Web Tutorial
Sub Category:
HTML Media Events Attribute
Uploaded by:
Admin