//[捕捉所有前端error]
window.onerror = function (errormessage, url, line, column, error) {
console.log("======================================================================")
console.log("url:{0}".replace('{0}', url))
console.log("error:{0}".replace('{0}', error))
console.log("errormessage:{0}".replace('{0}', errormessage))
console.log("line:{0}".replace('{0}', line))
console.log("column:{0}".replace('{0}', column))
console.log("======================================================================") var message = 'errorMessage:{0}\r\nurl:{1}\r\nline:{2}\r\ncolumn{3}\r\nerror:{4}' message = message.replace('{0}', errormessage);
message = message.replace('{1}', url);
message = message.replace('{2}', line);
message = message.replace('{3}', column);
message = message.replace('{4}', error);
$.post("/log", { errorMessage: message, functionName: url }, function () { });// 保存到log return true
}

window.onerror 捕捉所有的前端error的更多相关文章

  1. 基于window.onerror事件 建立前端错误日志

    QA不是万能的,用户的浏览环境非常复杂,很多情况无法靠测试用例去覆盖,所以最好建立一个前端错误日志,在真实用户端收集bug. try&catch是一个捕获前端错误的常见方法,比如: { //给 ...

  2. JS 拦截/捕捉 全局错误 全局Error onerror

    移动Web开发过程中,在真机测试时,往往会遇到一些PC调试无法重现的问题,这时候我们需要在手机上拦截错误,并有相应的输出. 公司和网上都有类似的工具/类库,但如果纯粹一个简单的调试,或许不需要引入工具 ...

  3. [译]window.onerror事件

    本文翻译youtube上的up主kudvenkat的javascript tutorial播放单 源地址在此: https://www.youtube.com/watch?v=PMsVM7rjupU& ...

  4. window onerror 各浏览器下表现总结

    window onerror 各浏览器下表现总结 做前端错误上报,必然离不开window onerror,但window onerror在不同设备上表现并不一致,浏览器为避免信息泄露,在一些情况下并不 ...

  5. firefox的window.onerror没有详细的出错提示

    当在firefox浏览器的a.htm页面中使用script标签加载某a.js出错时,如果放置window.onerror事件处理方法时,此方法获取到的错误信息都是固定的: {0:"Scrip ...

  6. window.onerror 应用实例

    详见: http://blog.yemou.net/article/query/info/tytfjhfascvhzxcytp75   window.onerror = function(sMessa ...

  7. 【转】window.onerror跨域问题

    What the heck is "Script error"? Ben Vinegar/ May 17, 2016 If you’ve done any work with th ...

  8. window.onerror事件用来自定义错误处理

    Event reference:      https://developer.mozilla.org/en-US/docs/Web/Events http://w3c.github.io/html/ ...

  9. window.onerror 错误监听,发到后台

    var doc = document.body || document.documentElement; var _onerror = Onerror(''); var Onerror = funct ...

随机推荐

  1. CALL FUNCTION 'BAPI_PO_CREATE1' 相关报错

    *&---------------------------------------------------------------------**& Report  ZQJ06*&am ...

  2. JSP&Servlet(转)

    第一篇:Web应用基础1.概念:  1.1应用程序分类     a.桌面应用程序:一般是指采用client/server即客户机/服务器结构的应用程序.     b.web应用程序:一般是指采用Bro ...

  3. ubuntu 14.04 用 shell 方便安装nginx

    nginx.sh apt-get install -y build-essential gcc g++ make m4 libpcre3 libpcre3-dev libcurl4-gnutls-de ...

  4. Machine Learning No.8: Clusting

    1. K-means algorithm 2. K-means optimization objective 3. Random initialization

  5. Linux Shell Script目录

    目录 Linux Shell基础 开始Shell编程 代码 示例代码查看:https://github.com/Furzoom/demo-C/tree/master/src/shell

  6. 编译debian内核

    玩腻了开发板,在pc上编译linux内核. debian 官方的内核文档见http://kernel-handbook.alioth.debian.org 我选择编译与当前内核版本对应的linux内核 ...

  7. 深入浅出 - Android系统移植与平台开发(七)- 初识HAL【转】

    本文转载自:http://blog.csdn.net/mr_raptor/article/details/8069588 版权声明:本文为博主原创文章,未经博主允许不得转载.   目录(?)[+]   ...

  8. 部署asp.net网站的小问题

    C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG   web.config  修改 trust level="Full"

  9. HTML5 拖放:在相册中对照片进行排序

    1. [代码]index.html     <div class="albums">    <div class="album" id=&qu ...

  10. Linux_学习_01_ 压缩文件夹

    二.参考资料 1.Linux下压缩某个文件夹命令