The general syntax of onerror event is as follows:
The onerror event is called by writing a function. This function is called by assigning to the onerror and the function written takes three arguments:
When an error occurs, the written function is invoked. The three values above are set to three variables. The function returns either true or false value using the return statement. The programmer would return the value false from the function if the programmer wants the browser to display the standard error message on the screen. If the programmer does not want to display the standard error message, then the returned value must be true from the function.
The output of the program would be
Error: Object expected
URL: http://URL displayed
Click to Proceed!!!!
In the above example program, the function display() has an error in it (the addalert is typed wrongly as addxlert). When the program reads this error, the onerror event handler fires and the function exfor( ) is called with the three parameters passed to it (the error message, the url of the page and the line number of error 18). These are displayed in the function which produced the output above.