本文介绍了javascript条件不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

function IP()
        {
          var net = new ActiveXObject("wscript.network");

         if((net.ComputerName).value="")
         {
          window.location.href="Welcome.aspx";
         return true;
         }
         else
         {
alert(net.UserDomain+': '+net.ComputerName);
         alert('SUCCESS')
         return true;
         }
        return false;
       }


这是我的功能,当他遇到
错误时,我想重定向网站用户Microsoft JScript运行时错误:自动化服务器无法创建对象
否则我想提醒成功..
但是我在某些客户端PC上出现错误,页面未重定向...


this is my function i want to redirect the website user when he Got error of
Microsoft JScript runtime error: Automation server can''t create object
else i want to alert with success..
but i m getting error on some client pc and page is not redirected...
is there any sollution?

推荐答案

function IP()
        {
         try
         {
            var net = new ActiveXObject("wscript.network");
            alert(net.UserDomain+': '+net.ComputerName);
            alert('SUCCESS');
         }
         catch ()
         {
            window.location.href="Welcome.aspx";
            return true;
         }
        return false;
       }


function IP()
        {
          var net = new ActiveXObject("wscript.network");

         if((net.ComputerName).value="")
         {
          window.location.href="Welcome.aspx";
         return true;
         }
         else
         {
alert(net.UserDomain+': '+net.ComputerName);
         alert('SUCCESS')
         return true;
         }
      //  return false;     dont use
       }


try
        {
           var net = new ActiveXObject("wscript.network");
           alert(net.UserDomain+': '+net.ComputerName);
           alert('SUCCESS');
        }
        catch(err)

        {
           window.location.href="Welcome.aspx";
        }


成功


这篇关于javascript条件不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-04 19:09