We help IT Professionals succeed at work.

PAC file - firefox and IE compatibility problem

bluesofa
bluesofa asked
on
2,587 Views
Last Modified: 2012-05-05
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?


Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2014

Commented:
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"; }
}

Author

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.

Author

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";

      
}
CERTIFIED EXPERT
Top Expert 2014
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

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.
CERTIFIED EXPERT
Top Expert 2014

Commented:
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.
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.