Skip to content

Instantly share code, notes, and snippets.

@smadey
Created January 9, 2019 14:05
Show Gist options
  • Save smadey/d1e9d5d2393a0a11fdaba737ace60288 to your computer and use it in GitHub Desktop.
Save smadey/d1e9d5d2393a0a11fdaba737ace60288 to your computer and use it in GitHub Desktop.
错误调试
window.onerror = function (msg, url, lineNo, columnNo, error) {
var string = msg.toLowerCase();
var substring = "script error";
if (string.indexOf(substring) > -1){
alert('Script Error: See Browser Console for Detail');
} else {
var message = [
'Message: ' + msg,
'URL: ' + url,
'Line: ' + lineNo,
'Column: ' + columnNo,
'Error object: ' + JSON.stringify(error)
].join(' - ');
alert(message);
}
return false;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment