Solved

PAC file - firefox and IE compatibility problem

Posted on 2006-06-18
6
2,015 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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
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…

708 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now