interviews.dotnetthread.com

↑ Grab this Headline Animator

Monday, July 28, 2008

How to do error handling in Javascript.

1. By using the try...catch statement (available in IE5+, Mozilla 1.0+, and Netscape 6+)
2. By using the onerror event. This is the old standard solution to catch errors (available since Netscape 3)

< html>
< head>
< script type="text/javascript">
var errorText=""
function message()
{
try
{
adddlert("Welcome guest!");
}
catch(err)
{
errorText+="Error description: " + err.description + "\n\n";
alert(errorText);
}
}
< /script>
< /head>

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

< /html>

Submit this story to DotNetKicks

No comments:

Post a Comment

Post your comments/questions/feedback for this Article.

 

Latest Articles