You register an onerror() event handler like this:
Navigator invokes the handler like this:
window.onerror(message, url, line)
A string that specifies the error message for the error that occurred.
A string that specifies the URL of the document in which the error occurred.
A number that specifies the line number at which the error occurred.
Note that while this event handler returns true to tell the browser to take no further action, most Form and form element event handlers return false to prevent the browser from performing some action, such as submitting a form. This inconsistency can be confusing.
You can turn off error handling entirely for a window by setting the onerror property of the window to null. If you will later want to turn error handling back on, you should first save the default error handler in a temporary variable, so you can restore the onerror property to its default value.
The following code shows how you might write and register an error handler for a window. Instead of reporting the error in a dialog box, this handler reports the details in a form that it creates directly in the document itself. The form contains a button that will send the details of the error off to the author of the web page.