try
{
// code
}
catch()
{
// Handle errors
}
For example
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
var txt="";
function Showmessage()
{
try
{
adddlert("JS try .. catch testing ....");
}
catch(err)
{
txt="There was an error on this page.";
alert(txt);
}
}
</script>
</head>
<body>
<input type="button" value="Click to View message" onclick="Showmessage()" />
</body>
</html>
No comments:
Post a Comment