轻轻松松用代理 - IE自动代理(auto-proxy)

相关文章:

虽然IE很难用——打倒IE!打到IE!——有时候还是得用它,比如国内的网上银行,还有某些垃圾网站。作为一个Web开发者,每天还得在IE下作修修补补的工作。就好像厕所虽然很臭,你也得每天进去一样——生活所迫啊。

Firefox有FoxyProxy可以灵活地配置代理切换,作为史上最臭名昭著的浏览器的IE怎么办呢?其实呢,IE也不是那么垃圾,写一个JavaScript(微软叫JScript)脚本就可以凑合着用了。

新建一个文件auto.pac,内容如下:

proxyDomains = [
'blogspot.com',
'facebook.com'
]
function isProxyDomain(host) {
	for (ii = 0; ii < proxyDomains.length; ii++) {
		if (dnsDomainIs(host, proxyDomains[ii])) {
			return true;
		}
	}
	return false;
}

function FindProxyForURL(url, host) {
	if (isProxyDomain(host)) {
		return 'PROXY localhost:8079';
	} else {
		return 'DIRECT';
	}
}

粗体的地方是代理地址,把它放在比如D盘根目录,然后在Internet 选项-链接-局域网设置那里如下配置:

重启IE后,就可以了。IE调用FindProxyForURL函数,我们判断一下被访问的域名是不是“特殊”的,如果是的话,就告诉IE通过代理访问,否则直接连接。

proxyDomains数组是需要通过代理访问的域名,可以自由添加。

可参考自动代理配置的官方文档

This entry was posted on Saturday, July 19th, 2008 at 7:52 pm and is filed under Apps. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

1 Comment »

2008-07-19 19:54:44

[...] 另外一篇文章,怎么为IE配置自动代理。 This entry was posted on Saturday, July 12th, 2008 at 10:03 am and is filed under Apps. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site. [...]

 
Name (required)
E-mail (required - never shown publicly)
URI
Your Comment (smaller size | larger size)

Please copy the string q2Pghs to the field below: