Answers:
你应该明确告诉它直接去。
控制此问题的最佳方法是检测您所在的网络。这是一个更复杂的proxy.pac示例:
function FindProxyForURL(url, host) {
// Variables
var proxy_LAN1 = "PROXY 10.61.9.200:8080; DIRECT;";
var LAN1_addr_ip4 = "10.97.100.0";
var LAN1_addr_ip6 = "fe80::b892:6a74:9635:*"; // Needed for FF/TB (Mozilla)
var proxy_no = "DIRECT";
var alert_done = 99;
//alert("My Addr: " + myIpAddress() + "\nURL: " + url + "\nHost: " + host);
// If address is local, always go direct
if( isPlainHostName(host) ) {
//alert("Local address so no proxy");
return proxy_no;
}
// Proxy if PC is on LAN1
if (isInNet(myIpAddress(), LAN1_addr_ip4, "255.255.255.0") || shExpMatch(myIpAddress(), LAN1_addr_ip6) ) {
//alert("LAN1 address & proxy");
return proxy_LAN1;
}
// Default to a direct connection
// alert("Default proxy (none)");
return proxy_no;
}
/*
NOTES:
Use alert("xxx") to find out what is happening. IE displays a pop-up, FF/TB use the error console
Can have multiple proxies to try. Separate each with ;
For local pac files, IE requires "file://c:\proxy.pac", FF/TB require file:///c:\proxy.pac" (extra /)
FF/TB - myIpAddress() returns an IPv6 rather than IPv4 address for Vista and Win7 so isInNet() doesn't work!
FUNCTIONS:
alert(text)
isPlainHostName(host)
shExpMatch(lookup, match)
isInNet(address, lookup.address, netmask)
myIpAddress()
dnsDomainIs(host, ".foobar")
EXAMPLES:
if (shExpMatch(url, "http://192.168.1.100*")) { return proxy_no; }
if (isInNet(myIpAddress(), "192.168.1.0", "255.255.255.0"))
*/
正如您所看到的,这会尝试检测我们是否在特定网络上,并且仅在设置为代理时才设置代理。