//[捕捉所有前端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. 关于Spring注解 @Service @Component @Controller @Repository 用法

    @Component 相当于实例化类的对象,其他三个注解可以理解为@Component的子注解或细化. 在annotaion配置注解中用@Component来表示一个通用注释用于说明一个类是一个spr ...

  2. plugin scala is incompatible with current installation

    源文链接:http://stackoverflow.com/questions/31927516/plugin-scala-is-incompatible-with-this-installation ...

  3. elementaryos必装软件

    所使用版本:elementaryos-0.4-stable-amd64.20160909.iso vmtools jdk sougouinput IntellijIEAD

  4. Hadoop- 流量汇总程序之如何实现hadoop的序列化接口及代码实现

    流量汇总程序需求 统计每一个用户(手机号)锁耗费的总上行流量.下行流量.总流量. 流程剖析 阶段:map 读取一行数据,切分字段, 抽取手机号,上行流量,下行流量 context.write(手机号, ...

  5. 大数据 - Zookeeper

    Zookeeper 1.  Zookeeper概念简介: Zookeeper是一个分布式协调服务:就是为用户的分布式应用程序提供协调服务 A.zookeeper是为别的分布式程序服务的 B.Zooke ...

  6. excel根据数据源变化的动态图表

    http://www.excelhome.net/lesson/article/excel/1798.html 这个链接讲的可以.

  7. POJ 2151 Check the difficulty of problems:概率dp【至少】

    题目链接:http://poj.org/problem?id=2151 题意: 一次ACM比赛,有t支队伍,比赛共m道题. 第i支队伍做出第j道题的概率为p[i][j]. 问你所有队伍都至少做出一道, ...

  8. sql中使用timestamp增量抽取数据

    网址:http://www.cnblogs.com/shuaifei/p/4469526.html 最近的项目中需要对上百万级的数据进行增量抽取操作,因此了解了一下TIMESTAMP的应用,特此记录 ...

  9. L97

    We are young. So let's set the world on fire. We can burn brighter than the sun.我们是青年,让我们点亮世界,释放生命,胜 ...

  10. javascript基础知识整理(不定时更新)

    1.js中真与假的定义: 真:true,非零数字,非空字符串,非空对象 假:false,数字零,空字符串,空对象(null),undefined 2.使用for循环对json进行循环操作 for(va ...