开发者

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

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.


window.onerror handler is the answer. Read this - http://www.javascriptkit.com/javatutors/error.shtml

To get more information about the script that caused the error, read this - http://www.javascriptkit.com/javatutors/error3.shtml

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜