PAC file - firefox and IE compatibility problem

Hi,

I've written this PAC file which works fine in firefox, but not in IE...

function FindProxyForURL(url, host)

{
            
      if (shExpMatch(host, "*.blah.blah.blah.uk") ||
            shExpMatch(host, "*.blah.blah.blah.uk") ||
            isInNet(host, "10.225.64.10", "255.255.255.255") ||
            isInNet(host, "10.137.166.0", "255.255.255.0") ||
            isPlainHostName(host))

            return "DIRECT";

      else if       (!isInNet(myIpAddress(), "10.137.166.0", "255.255.255.0"))
            
            return "DIRECT";

      else

            return "PROXY 10.137.166.3:8080";
      
}

The (!isInNet(myIpAddress(), "10.137.166.0", "255.255.255.0")) bit wouldn't work when it was in the first if statement.  

When I moved it to the else if section, the script works perfectly in firefox, but still not ok in IE.

I want to leave this bit so it selects if not on that net, so laptop users can use it even if they have different home network configs....

Can someone suggest how to fix this to work in firefox and IE?

Or have I got completely the wrong way of doing this?


bluesofaAsked:
Who is Participating?
 
giltjrConnect With a Mentor Commented:
Not sure if the brackets have something to do with it or not. But I do know what I posted did work under IE V6 SP2.

However, how do you have IE configured to get the PAC file.  If you setup IE, or Firefox, to pull it from a file that is on a network share or from a webserver that is on your internal network only, then when they are NOT on you LAN IE/Firefox can't find it and will go direct.

I have not tested it, but you should be able to:

function FindProxyForURL(url, host)

{
     if (shExpMatch(host, "*.blah.blah.uk") ||
          shExpMatch(host, "*.blah.blah.uk") ||
          isInNet(host, "10.225.64.10", "255.255.255.255") ||
          isInNet(host, "10.137.166.0", "255.255.255.0") ||
          isInNet(myIpAddress(), "192.168.1.0", "255.255.255.0") ||
          isPlainHostName(host))

          return "DIRECT";

     
     else

          return "PROXY 10.137.166.3:8080";

     
}
function FindProxyForURL(url, host)

{
     if ( (! isInNet(myIpAddress(), "192.168.1.0", "255.255.255.0")) ||
          shExpMatch(host, "*.blah.blah.uk") ||
          shExpMatch(host, "*.blah.blah.uk") ||
          isInNet(host, "10.225.64.10", "255.255.255.255") ||
          isInNet(host, "10.137.166.0", "255.255.255.0") ||
          isPlainHostName(host))

         {  return "DIRECT"; }

     
     else

          return "PROXY 10.137.166.3:8080";

     
}
0
 
giltjrCommented:
What version of IE.  The following works for me with IE6 SP2

function FindProxyForURL(url, host)
{
if (!isInNet(myIpAddress(), "192.168.0.0", "255.255.0.0" ))       
      { return "DIRECT"; }
 else
         { return "PROXY 192.168.1.1:8080"; }
}
0
 
bluesofaAuthor Commented:
We're using IE6 SP2.

Isn't that basically the same function, but with some { } brackets - are they called braces?

Do the brackets have something to do with it?  I can understand what the functions are trying to achieve, but just don't know the syntax.

0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
bluesofaAuthor Commented:
A bit more info that might make things clearer...

This works absolutley fine in IE6 SP2.  I just want the myIpAddress to be NOT 10.137.0.0 instead, so other user's laptops can run the same script, not matter what their home IP configs.


function FindProxyForURL(url, host)

{
      if (shExpMatch(host, "*.blah.blah.uk") ||
            shExpMatch(host, "*.blah.blah.uk") ||
            isInNet(host, "10.225.64.10", "255.255.255.255") ||
            isInNet(host, "10.137.166.0", "255.255.255.0") ||
            isInNet(myIpAddress(), "192.168.1.0", "255.255.255.0") ||
            isPlainHostName(host))

            return "DIRECT";

      
      else

            return "PROXY 10.137.166.3:8080";

      
}
0
 
bluesofaAuthor Commented:
The bit that works is the first part - pulling it from a place that forces a direct connect when they're not on the network and can't get the pac file.  Beyond what I'd asked - hence the grade A.

The NOT operator still won't work in IE6 SP2 for me, but that doesn't matter now.  

Thanks for your help.
0
 
giltjrCommented:
Glad to see you have a workable solution.  Doing that makes it easier to maintain also.  It a bear if you have the file on 100 laptops that you have to push out.  Thanks for the points and the grade.
0
All Courses

From novice to tech pro — start learning today.