Try my app Expense Manager @ google play and amazon store.

Tuesday, June 26, 2012

Java Script Tutorial 17 : JavaScript Try .. Catch

JavaScript try .. catch statement allows you to test a block of code for errors. The try block contains the code to be run, and the catch block contains the code to be executed if an error occurs. Syntax of JS try .. catch is :

       // code
       // Handle errors

For example

<!DOCTYPE html>
<script type="text/javascript">
var txt="";
function Showmessage()
            adddlert("JS try .. catch testing ....");
            txt="There was an error on this page.";
   <input type="button" value="Click to View message" onclick="Showmessage()" />

No comments:

Post a Comment

Follow by Email

Google+ Badge