Skip to content

Instantly share code, notes, and snippets.

View itsky365's full-sized avatar

穿山甲 itsky365

  • 杭州市莫干山路
View GitHub Profile
0x90f4561830d299740838a6ff0deaca26266c643b
@itsky365
itsky365 / README.md
Created October 13, 2013 14:57 — forked from nikcub/README.md

捕捉浏览器中的JS运行时错误,主要通过监听window.onerror来实现。但是对于不同的脚本执行方式以及不同的浏览器,能捕获到的信息会有区别。

window.onerror 讲接收3个参数:

  • msg:错误描述,比如:a is not defined
  • url:出错脚本所在的url
  • lineNumber:出错脚本的行数

本文将对不同浏览器和不同的脚本执行方式进行测试,并总结这些区别。