I believe we covered this briefly in our last series, but we will do so a little more in depth here. The OnError event occurs whenever there is a script error on the page. To use the event, you create a function to deal with the error. When the error occurs, the function is called by the Onerror event handler, which consists of three arguments: the error message (msg), the URL of the page where the error occurred (url), and the line where the error occurred (line). Here it is in code:
txt="An error has occurred.nn"
txt+="Error: " + msg + "n"
txt+="URL: " + url + "n"
txt+="Line: " + l + "nn"
txt+="Click OK to continue.nn"
<input type="button" value="Click to trigger the error" onclick="message()" />
In the code above, we create a function named handletheerror that will occur when the Message function fails to work (note that this function fails to work because the adddblerto should actually be code for an alert, but has many typos; if you fixed the code, the onerror event would never occur). It triggers a pop-up box that tells you an error has occurred, the URL at which it occurred, and on which line in the code the error appears.