Window.onerror = function (msg,url,line,col,error) {//No URL is not escalated! The escalation also does not know the error if (msg! = "Script error." &&!url) {return true; }//Asynchronous Way//I have encountered an Ajax blocking escalation in window.onunload//due to a client forcing shutdown WebView caused this blockage to escalate with network Error//I guess the window.onerror here The flow is bound to execute before it is closed//and the escalation after leaving the article is a loss for the business//So I'm going to banish the execution here to the asynchronous event to execute//The exception number of the script is reduced by 10 times times setTimeout (function () {var da Ta = {}; Not all browsers support col parameter col = col | | (window.event && window.event.errorCharacter) | | 0; data.url = URL; Data.line = line; Data.col = col; if (!! Error &&!! Error.stack) {//If the browser has stack information//directly using DATA.MSG = Error.stack.toString (); }else if (!! Arguments.callee) {//try to get stack information via callee var ext = []; var f = arguments.callee.caller, c = 3; Here only three stack information is taken while (F && (--c>0)) {Ext.push (f.tostring ()); if (f = = = F.caller){break;//If there is a ring} f = F.caller; ext = Ext.join (","); data.msg = ext; }//Upload data to the background! },0); return true;};
JS code error Monitoring code