W3School TIY
编辑您的代码:
<html> <head> <script type="text/javascript"> var txt="" function message() { try { adddlert("Welcome guest!") } catch(err) { txt="本页中存在错误。\n\n" txt+="错误描述:" + err.description + "\n\n" txt+="点击“确定”继续。\n\n" alert(txt) } } </script> </head> <body> <input type="button" value="查看消息" onclick="message()" /> </body> </html>
查看结果: