js中的try/catch
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>robot</title> <script> window.onload = function(){ try{ var message = document.getElementById("message"); } catch (error){ console.log("Error:" + error.message); } } </script> </head> <body> </body> </html>