转载请注明来源:https://www.cnblogs.com/hookjc/

<html>
<head>
<script type="text/javascript">
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!")
}
</script>
</head>
<body>
<input type="button" value="View message" onclick="message()" />
</body>
</html>

 

注:当点击按钮时出现错误,则触发onerror事件 即onerror=handleErr    去执行handleErr方法,msg为错误信息,url为当前显示的url地址,l表示错误的行号

来源:python脚本自动迁移

相关文章:

  • 2022-12-23
  • 2021-12-13
  • 2022-12-23
  • 2021-10-02
  • 2022-02-22
  • 2021-12-06
  • 2021-09-24
  • 2022-12-23
猜你喜欢
  • 2021-07-14
  • 2021-08-04
  • 2022-12-23
  • 2021-10-16
  • 2021-08-15
相关资源
相似解决方案