源代码
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>享学课堂</title> </head> <body> <h1>JavaScript Errors</h1> <p>不能评估包含语法错误的代码:</p> <p id="demo"></p> <script> try { eval("alert('Hello)"); } catch(err) { document.getElementById("demo").innerHTML = err.name; } </script> </body> </html>
运行结果