Press "Enter" to skip to content

Onerror Example in JavaScript

Definition :

This is a event which triggers a function whenever an exception has been encountered in the image.

Program :

<html>

   <head>

      <script language=”javascript”>

                      function display()

                                  {

                                                alert(“sorry couldn’t find image”);

                                                 }

                                </script>

    </head>

                <body>

                  <img src=”Desert.jpg” onerror=”display()”/>

                </body>

</html>

Be First to Comment

    Leave a Reply

    Your email address will not be published. Required fields are marked *