Click here to Skip to main content
15,888,984 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
C#
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;
       }

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?
Posted
Updated 31-Aug-12 21:10pm
v3
Comments
Zoltán Zörgő 1-Sep-12 3:12am    
And what is the "error"?
Devang Vaja 1-Sep-12 3:17am    
see the question
"Microsoft JScript runtime error: Automation server can't create object"
is error at that error i want to redirect

It is very likely to be a browser security related issue. Since yo can not rely on the client I would implement this redirection on server side. It looks that you are in a domain environment, thus you can easily check on server side if the computer is domain member or not.

But you can put it simply in a try catch block, like this:

JavaScript
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;
       }
 
Share this answer
 
Comments
Devang Vaja 1-Sep-12 4:26am    
thnx so much
C#
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
       }
 
Share this answer
 
i tried this
C#
try
        {
           var net = new ActiveXObject("wscript.network");
           alert(net.UserDomain+': '+net.ComputerName);
           alert('SUCCESS');
        }
        catch(err)

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

it's successful
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900