JavaScript中我们可以定义一个通用的错误处理程序,只要页面出现JS错误就自动调用已经定义好的错误处理程序
onerror=handleErr; var txt=""; function handleErr(msg,url,l) { 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; } function message() { adddlert("Welcome guest - 75271.com"); }