源代碼
點擊運行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>教程</title> <script> onerror=handleErr; var txt=""; function handleErr(msg,url,l){ txt="該頁面有一個錯誤 "; txt+="錯誤: " + msg + " "; txt+="URL: " + url + " "; txt+="行: " + l + " "; txt+="點擊確定繼續。 "; alert(txt); return true; } function message(){ adddlert("Welcome guest!"); } </script> </head> <body> <input type="button" value="查看消息" onclick="message()" /> </body> </html>
運行結果