源代碼
點擊運行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>教程</title> <script> var txt=""; function message(){ try{ adddlert("Welcome guest!"); } catch(err){ txt="本頁有一個錯誤。 "; txt+="單擊確定繼續跳轉 "; txt+="或者單擊取消返回 "; if(confirm(txt)){ document.location.href="http://www.sharebody.com/"; } } } </script> </head> <body> <input type="button" value="查看消息" onclick="message()" /> </body> </html>
運行結果