开发者

javascript error listener

开发者 https://www.devze.com 2022-12-27 16:55 出处:网络
i try using window.attachEvent (or addEventListener) to capture js errors my callback function gets only one event parameter

i try using window.attachEvent (or addEventListener) to capture js errors my callback function gets only one event parameter

my question is: how do i get line number and source file of the error from this event?

the alternative usage window.onerror=callback; works but an event listener has other benefits thus 开发者_运维百科im giving it a try


You won't get line number and source file from an error in IE except via window.onerror. In Firefox, Error objects have lineNumber and fileName properties, so if you've caught an error using try/catch you can use these properties.

0

精彩评论

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