js_错误处理机制

来源:互联网 发布:p2p监控软件 编辑:程序博客网 时间:2024/05/22 04:55

1.try{}catch(err){}

<span style="background-color: rgb(255, 255, 204);"><span style="font-size:14px;"><span style="color:#CC0000;"><script type="text/javascript"></span><span style="color:#CC0000;">function message(){   var txt=""   try{  adddlert("Welcome guest!");  }//测试代码的执行   catch(err){txt="There was an error on this page.\n\n";  //提示信息1txt+="Click OK to continue viewing this page,\n";  //提示信息2txt+="or Cancel to return to the home page.\n\n";  //提示信息3        if(!confirm(txt)) //confirm()返回false就执行    {document.location.href="http://www.w3school.com.cn/"}//重定向  }//错误处理机制}message();</script></span></span></span>


0 0
原创粉丝点击