JAVASCRIPT ONERROR EVENT FOR EXCEPTION HANDLING
Run
<html>
    <head>
        <title>
            Using onerror Event
        </title>
        <script type="text/javascript">
        // using onerror event to handle error
        window.onerror = function(ermessage, url, line)
        {
            document.write(ermessage+"<br/>");
            document.write(url+"<br/>");
            document.write(line+"<br/>");
        }
        // the below line will cause error
        document.write(n);
        </script>
    </head>
    <body>
        <!-- HTML body -->
    </body>
</html>