error的处理:
1.try{
throw "errorinfomation";
}
catch(e){
if(e =="errorinfomation"){
}
}
2.<script type="text/javascript"> //事件触发
//如何使用 onerror 事件捕获网页中的错误。(chrome、opera、safari 浏览器不支持)
οnerrοr=handleErr //function可以赋值
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!");
}
</script>
</head>
<body>
<input type="button" value="View message" οnclick="message()" />
</body>
注意:
JavaScript 对大小写敏感
可以
在文本字符串内部使用反斜杠对代码进行折行:document.write("Hello
\World!"); ----------->只适用于字符串。