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