源代碼
點擊運行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>教程</title> <script> var txt=""; function message(){ try { adddlert("Welcome guest!"); } catch(err) { txt="本頁有一個錯誤。 "; txt+="錯誤描述:" + err.message + " "; txt+="點擊確定繼續。 "; alert(txt); } } </script> </head> <body> <input type="button" value="查看消息" onclick="message()" /> </body> </html>
運行結果