How can I detect if the browser has encountered a JavaScript error ... in JavaScript?

Posted by RichH on Stack Overflow See other posts from Stack Overflow or by RichH
Published on 2010-04-02T20:27:52Z Indexed on 2010/04/02 20:33 UTC
Read the original article Hit count: 367

For automated testing reasons I want to detect if the browser has encountered JavaScript errors for a page. The type of things that would cause the red numbers in the bottom right in Firebug or yellow warning icon in the Internet Explorer status bar. These JS errors could come from any one of a large numbers of scripts.

How in JavaScript can I detect these browser errors? Cross browser solutions prefered, but hey, I'll take anything!

As a bonus it would also be great to know the script that caused the error.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about automated-tests