JavaScript onerror Event

Any error that is not handled by the try-catch statement causes the onerror event to fire on the window object.

The onerror event doest not create an event object, it is called by the object of the window that has the errors.

The onerror event accepts the three arguments which are:

  • the error message
  • the URL of the web page on which the error occurred
  • the line number that contains the error

Here is the general form to use onerror event in JavaScript to display the error message.

window.onerror = function(errormessage, url, line)

JavaScript Online Test

« Previous Tutorial Next Tutorial »

Follow/Like Us on Facebook

Subscribe Us on YouTube