//[捕捉所有前端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. Java for LeetCode 107 Binary Tree Level Order Traversal II

    Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left ...

  2. Java for LeetCode 084 Largest Rectangle in Histogram【HARD】

    For example, Given height = [2,1,5,6,2,3], return 10. 解题思路: 参考Problem H: Largest Rectangle in a Hist ...

  3. 微信小程序开发:学习笔记[1]——Hello World

    微信小程序开发:学习笔记[1]——Hello World 快速开始 1.前往微信公众平台下载微信开发者工具. 地址:https://mp.weixin.qq.com/debug/wxadoc/dev/ ...

  4. before-request , after-request

    1 . flask的中间件 1)@app.before_request     # 请求进入视图函数之前,类似于django中间件的request_process 2)@app.after_reque ...

  5. property 中的strong 与weak

    strong关键字与retain关似,用了它,引用计数自动+1,用实例更能说明一切 @property (nonatomic, strong) NSString *string1; @property ...

  6. P4298 [CTSC2008]祭祀

    P4298 [CTSC2008]祭祀 传递闭包跑一遍按联通建图 $(1)$最长反链长度=最小链覆盖=n-最大匹配 $(2)$定义作为最大匹配出现在左端点的集合为$S$,作为最大匹配出现在右端点的集合为 ...

  7. pkg-config设置

    pkg-config在一些源码管理中会被使用到. 介绍 上网查资料,知道了pkg-config这个东西,下面简单介绍一下. pkg-config提供了下面几个功能: 检查库的版本号.如果所需要的库的版 ...

  8. M1卡破解(自从学校升级系统之后,还准备在研究下)【转】

    本文转载自: M1卡说明及使用proxmark3破解方法 看了网上写的一些关于M1卡的文章,多数有些误导之嫌.首先谈谈M1卡的规格,M1卡的容量为1KB,好多网上写8KB,这里其实是有个误区,应该是8 ...

  9. Spring Boot2.0之整合log4j

    传统方式打印日志比较复杂, 每次打印需要定义全局变量 private static final Logger logger = LoggerFactory.getLogger(SjpControlle ...

  10. 算法(Algorithms)第4版 练习 链表类 1.3.19~1.3.29

    package com.qiusongde.linkedlist; import java.util.Iterator; import java.util.NoSuchElementException ...