[JavaScript] JavaScript通过try...catch捕捉错误然后跳转的代码 →→→→→进入此内容的聊天室

来自 , 2020-01-03, 写在 JavaScript, 查看 154 次.
URL http://www.code666.cn/view/a3a3e8b3
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <script>
  5. var txt="";
  6. function message()
  7. {
  8. try
  9.   {
  10.   adddlert("Welcome guest!");
  11.   }
  12. catch(err)
  13.   {
  14.   txt="There was an error on this page.\n\n";
  15.   txt+="Click OK to continue viewing this page,\n";
  16.   txt+="or Cancel to return to the home page.\n\n";
  17.   if(!confirm(txt))
  18.     {
  19.     document.location.href="http://www.sharejs.com/";
  20.     }
  21.   }
  22. }
  23. </script>
  24. </head>
  25.  
  26. <body>
  27. <input type="button" value="View message" onclick="message()" />
  28. </body>
  29.  
  30. </html>
  31.  
  32. //javascript/7844

回复 "JavaScript通过try...catch捕捉错误然后跳转的代码"

这儿你可以回复上面这条便签

captcha