JAVA SCRIPT-->>Try...Catch Statement

66
rate this page

By unique7


The 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.

<html><head><script type="text/javascript">

var txt=""

function message()

{

try

{

adddlert("Welcome guest!")

}

catch(err)

{

txt="There was an error on this page.\n\n"

txt+="Click OK to continue viewing this page,\n"

txt+="or Cancel to return to the home page.\n\n"

if(!confirm(txt))

{

document.location.href="http://yahoo.com/"

}

}

}

</script></head>

<body>

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

</body></html>

Comments

RSS for comments on this Hub Small RSS Icon

No comments yet.

Submit a Comment

Members and Guests

Sign in or sign up and post using a hubpages account.


optional



No Amazon results found
working