Try Catch Using JavaScript

  1. <html>  
  2.   
  3. <head>  
  4.     <script type="text/javascript">  
  5.         var txt = "";  
  6.   
  7.         function message() {  
  8.             try {  
  9.                 adddlert("Welcome guest!");  
  10.             } catch (err) {  
  11.                 txt = "There was an error on this page.\n\n";  
  12.                 txt += "Error description: " + err.description + "\n\n";  
  13.                 txt += "Click OK to continue.\n\n";  
  14.                 alert(txt);  
  15.             }  
  16.         }  
  17.     </script>  
  18. </head>  
  19.   
  20. <body> <input type="button" value="click" onclick="message()" /> </body>  
  21.   
  22. </html>