Is there some way to access webpage warning/error details using JavaScript?
For instance, errors in IE show up in the bottom left corner like so:
I would like to able to access the details of this error (in IE as well as other browsers if possible) using JavaScript.
Any suggestions?
EDIT: I’m not looking for debuggers. I want to access the content of the error details/error console. Alternately, figuring out how to create a global exception handler equivalent for JavaScript would help too
You may want to use the
window.onerrorevent. You can consider this event as a sort of global exception handler. The value returned byonerrordetermines whether the browser displays a standard error message. If you return false, the browser displays the standard error message in the JavaScript console. If you return true, the browser does not display the standard error message. (Source)You can also use traditional exception handling in JavaScript to catch run-time errors.
The output of the above would be:
EDIT: As noted by psychotik’s comment, the
window.onerrorevent does not work in Google Chrome. (Source)