Get error file url : onerror « Window « JavaScript Tutorial






<html>
    <head>
        <title>OnError Example</title>
        <script type="text/javascript">
            window.onerror = function (sMessage, sUrl, sLine) {
                alert("An error occurred " + "\nURL: " + sUrl);
                return true;
            }
        </script>
    </head>
    <body onload="nonExistentFunction()">
    </body>
</html>








19.8.onerror
19.8.1.Window on error event
19.8.2.Return true from window onerror event
19.8.3.Get error message
19.8.4.Get error file url
19.8.5.Get error line number
19.8.6.Error occurs before the onerror event handler (Error will not be displayed)