1

i've already a working proxy.pac file. I'd like the clients to use different proxyserver depending on their web browser.

No problem I thought. There are many java script snippets out there, to detect browser name/version.

The samples I found uses all "navigator.appName". That works fine if I test this on a regular website. When I put the same into my proxy.pac, it doesn't work. The navigator object doesnt seem to exist.

Has anyone out there a suggestion how to switch the proxy according to the user agent?

My goal is, that all IE6 uses a specific proxy, where the rest just use the default proxy.

Background: IE6 does not support Kerberos authentication, which is used on the default proxy. Therefore I setup an additional proxy with LDAP authtentication.

Thanks in advance for any help.

Captain Obvlious
  • 19,754
  • 5
  • 44
  • 74
casper
  • 821
  • 1
  • 8
  • 19

2 Answers2

0

Maybe there are some less or more subtle javascript engine differences between the browsers that one can spot, using for example
if (typeof(someIESpecificFunction) != "undefined")
or using try and catch
or comparing results of some builtin functions for subtle differences

http://en.wikipedia.org/wiki/Comparison_of_layout_engines_(ECMAScript) and http://www.robertnyman.com/javascript/index.html may be helpful for a start?

Update: one more browser-version specific behaviour:

from http://technet.microsoft.com/en-us/library/dd361918.aspx:

    function FindProxyForURL(url, host)
    {
        if(weekdayRange("WED", "SAT", "GMT"))
            return "PROXY proxy:80";
        else
            return "DIRECT";
    }

The weekdayRange( <day1> [,<day2>] [,<GMT>] ) function returns whether the current system time falls within the range specified by the parameters <day1>, <day2>, and <GMT>. Only the first parameter is necessary. The GMT parameter sets the times to be taken in GMT rather than in the local time zone.

Note Where the function is called with <day1> == <day2>, previous versions of Internet Explorer would yield results different from results with Netscape Navigator. Specifically, previous versions of Internet Explorer would interpret this day range as an entire week, while Internet Explorer 6 and Netscape Navigator interpret the range as a single day. For example, if the current day is Monday, the call weekdayRange("TUE", "TUE") returns TRUE on previous versions of Internet Explorer and FALSE on Internet Explorer 6 and Netscape Navigator.

Update 2: According to http://blogs.msdn.com/b/wndp/archive/2006/07/18/ipv6-wpad-for-winhttp-and-wininet.aspx one should be able to distinguish also IE7 from older IE versions (other browsers may and may not support these extensions, like for example mentioned here about Chrome: http://code.google.com/p/pactester/issues/detail?id=9)

Based on the information so far it should be possible to distinguish IE 5.5, IE 6, IE 7, IE 8, IE 9?

Please let us know if You find anything like that useful.

Roland Pihlakas
  • 4,246
  • 2
  • 43
  • 64
  • Sorry for the late reply. I did a work-around, as no solution I found did work properly. I point the browser to a PHP script proxy.php which parse the user-agent header and send out one proxy.pac for ie6 and one for all others. – casper Aug 13 '12 at 17:15
0

You may try detecting IE inside PAC script via Conditional Compilation: const ifIE = /*@cc_on!@*/false;.
Conditional Compilation may vary depending on new or old IE/Edge versions.

I haven't done any testing of this answer --, please, let us know if it works in comments.

Community
  • 1
  • 1
ilyaigpetrov
  • 3,657
  • 3
  • 30
  • 46