onerrorexample4.htm
来自「javascript源码」· HTM 代码 · 共 18 行
HTM
18 行
<html>
<head>
<title>OnError Example</title>
<script type="text/javascript">
alert("Syntax error.";
window.onerror = function (sMessage, sUrl, sLine) {
alert("An error occurred:\n" + sMessage + "\nURL: " + sUrl + "\nLine Number: " + sLine);
return true;
}
</script>
</head>
<body onload="nonExistentFunction()">
<p>The syntax error in this page occurs before the <code>onerror</code>
event handler is assigned, therefore the browser intercepts the error
and the custom error message isn't displayed.</p>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?