It is necessary for several of our laptops to operate on both our own and customer-based networks. This often involves switching proxy settings, which we did via a custom proxy.pac file at first (after some help from you here). Now, one of the networks we use has their own proxy.pac that we must use which means that currently, we have to manually change our proxy.pac location for that network.
So, is there a way to write a proxy.pac such that it defers to another proxy.pac in some circumstances?
No, not within a static .pac file. The problem would be that you would end up redefining the FindProxyForURL() function when the second file was loaded which would set off the javascript interpreter.
You would need to develop a dynamic page (ASP, PHP, etc) that would implement the required logic and then, based on the decision, read in the contents of the desired .pac file and serve it back to the client. I used to do this to build in some dynamic load balancing between proxies that I had in different physical locations and it worked well for me.
If you choose to go this route, make sure that the script you write sets the return mime type to application/x-ns-proxy-autoconfig or application/x-javascript-config, otherwise your browser will not recognize it as a pac file.
After getting annoyed with IE for not having a quick and easy way to turn proxy settings off, this question inspired me to write this PAC file in PHP.
It determines whether a request for the file is made from internally (in which case, use the proxy server) or externally: go direct. Perhaps someone can adjust it for their own needs.
I have now adjusted my Group Policy settings so that all browsers will point to this file which is located on a webserver within the firewall. Now if laptops go offsite, their proxy file will change automatically without the need to reconfigure the browser's proxy setting.
Edit: updated to match local IP address hosts also...
You might be able to use WPAD (web proxy auto discovery) to distribute different proxy.pac files in different networks.
But you'll need a simple webserver in each of the networks and the search domain provided by dhcp must be different in each of the networks. If each webserver is hosting a different proxy.pac file under the URL http://wpad[.dhcp-search-domain.com]/wpad.dat, then all you need to do is set "autodiscover" in your browser's proxy settings and restart the browser each time you switch between networks.
If you are really lucky, your customer already has a working proxy autodiscovery and you just missed it, due to your static proxy.pac config...