Solved

PAC file - firefox and IE compatibility problem

Posted on 2006-06-18
6
2,056 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?


0
Comment
Question by:bluesofa
  • 3
  • 3
6 Comments
 
LVL 57

Expert Comment

by:giltjr
ID: 16931478
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
 

Author Comment

by:bluesofa
ID: 16932738
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
 

Author Comment

by:bluesofa
ID: 16932885
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 57

Accepted Solution

by:
giltjr earned 500 total points
ID: 16934429
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
 

Author Comment

by:bluesofa
ID: 16936197
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
 
LVL 57

Expert Comment

by:giltjr
ID: 16936916
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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question