JavaScript Errors - Throw and Try

<!DOCTYPE html>

<html>

<head>

<script>

var txt="";

function message()

{

try

    {

    adddlert("Welcome guest!");

    }

catch(err)

    {

    txt="There was an error on this page.nn";

    txt+="Error description: " + err.message + "nn";

    txt+="Click OK to continue.nn";

    alert(txt);

    }

}

</script>

</head>



<body>
<input type="button" value="View message" onclick="message()" />

</body>



</html>

Java script errors by karan chanana

  • 1.
    JavaScript Errors -Throw and Try <!DOCTYPE html> <html> <head> <script> var txt=""; function message() { try { adddlert("Welcome guest!"); } catch(err) { txt="There was an error on this page.nn"; txt+="Error description: " + err.message + "nn"; txt+="Click OK to continue.nn"; alert(txt); } } </script> </head> <body>
  • 2.
    <input type="button" value="Viewmessage" onclick="message()" /> </body> </html>