onerror 事件

  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. onerror=handleErr
  5. var txt=""
  6.  
  7. function handleErr(msg,url,l)
  8. {
  9. txt="本页中存在错误。\n\n"
  10. txt+="错误:" + msg + "\n"
  11. txt+="URL: " + url + "\n"
  12. txt+="行:" + l + "\n\n"
  13. txt+="点击“确定”继续。\n\n"
  14. alert(txt)
  15. return true
  16. }
  17.  
  18. function message()
  19. {
  20. adddlert("Welcome guest!")
  21. }
  22. </script>
  23. </head>
  24.  
  25. <body>
  26. <input type="button" value="查看消息" onclick="message()" />
  27. </body>
  28.  
  29. </html>