检测网站的JS报错

    window.onerror = function (errorMessage, scriptURI, lineNumber, columnNumber, errorObj) {
        var context = "错误路径:" + window.location.href + ";\n"
            + "错误信息:" + errorMessage + ";\n"
            + "出错文件:" + scriptURI + ";\n"
            + "出错行号:" + lineNumber + ";\n"
            + "出错列号:" + columnNumber + ";\n"
            + "错误详情:" + errorObj + "。\n";
        //获取到错误之后上传。
    }

 

posted @ 2019-09-30 10:50  _Iniesta  阅读(314)  评论(0编辑  收藏  举报