重新window.onerror方法就行了
window.onerror = handleError function handleError(msg,url,l) { var txt="There was an error on this page.\n\n" txt+="Error: " + msg + "\n" txt+="URL: " + url + "\n" txt+="Line: " + l + "\n\n" txt+="Click OK to continue.\n\n" alert(txt) return true } //如果返回值为 false,则在控制台 (JavaScript console) 中显示错误消息。反之则不会