首页 > 常识 > 互联网 > 上网浏览 > 常见问题

IE中使用自动配置脚本的几种设置方法

作者:yiluokuang.com  时间:2015-08-19
描述:在Internet Explorer中可以通过设置自动配置脚本来控制哪些地址通过代理访问,哪些地址不通过代理访问。

在局域网设置对话框中填上代理地址,一切选项都由浏览器自动设置。上面的“自动检测设置”最好关掉,否则很会拖慢浏览速度。

有不少朋友的机器上网的时候会出现慢或者无法联网的问题,在查看Internet选项的时候,发现“局域网设置”——》“使用自动配置脚本”项被莫名其妙的修改为 file://c:/joydown/*.pac,更气人的是你无法取消它,即便是你去掉对勾并点击“确定”,你重新看Internet选项的时候,“局域网设置”“使用自动配置脚本”依旧是file://c:/joydown/*.pac,即便是使你重新启动了计算机这个问题依旧。

原因到底是什么呢?最大的可能是你的计算机上安装了pp加速器或其他加速器所致。安装pplive的时候或者是PPS软件默认都会安装pp加速器,而pp加速器就是修改这个局域网设置的软件。

解决办法:在控制面板—添加删除程序中删除pp加速器,重启计算机即可。

IE中使用自动配置脚本的几种设置方法

在Internet Explorer中可以通过设置自动配置脚本来控制哪些地址通过代理访问,哪些地址不通过代理访问。因为一般情况下,直接访问都要比通过代理访问快,而反复地切换代理无疑是一件麻烦的事情。

代理自动配置脚本是一个pac文件,是用javascript语言写的文本文件,格式由netscape定义,IE通过jsproxy.dll来处理自动配置脚本。这个pac文件可以以http服务的方式提供,也可以使用本地文件。这两种方式的设置办法分别是:

1.http://host/xxx/proxy.pac
2.file://c:tempproxy.pac

在其他浏览器,比如firefox中,后一种可能会被转化为file:///c:/temp/proxy.pac

如果自动配置脚本以windows文件共享的方式提供,这两个办法就行不通了,这时需要将共享目录映射为本地驱动器然后用第二种格式访问,或者采用第三种格式:

?file://\hostxxxproxy.pac

这个格式很怪,但经过试验,在IE6.0中是有效的。在firefox中这一写法会被转化为file:////host/xxx/proxy.pac,但无法正常使用,看来又是windows和IE的专属用法。

局域网设置里使用自动配置脚本去不掉

局域网设置里的使用自动配置脚本被勾选,地址是http://localhost:9000/application.pac]http://localhost:9000/application.pac”去不掉了,怎么回事

PPLiveVA 视频加速器插件 应用程序的原因

局域网设置自动配置脚本文件的写法与用途

首先我们先来介绍一下自动配置脚本文件:
打开IE,点击"工具"--"Internet选项"--"局域网设置",你就可以看到"使用自动配置脚本"
自动配置脚本起的作用就是,当IE访问网页的时候会根据脚本文件里面界定的内容来访问。比方说,你在脚本文件里面限定了访问某些IP使用某个代理的时候,访问另外一些IP使用另外的代理,这就很方便通过脚本文件来完成。
一个PAC文件其实就是一个文本文件,最简单的格式就是包含一个叫FindProxyForURL的JScript函数,IE通过传入两个变量来调用这个函数,一个是用户浏览的地址URL全路经,一个是这个URL中的主机名部分(host)。
这个FindProxyForURL函数有三种可能的字符串返回值,一是"DIRECT",就是直接连接,不通过代理;二是"PROXY proxyaddr:port",其中proxyaddr和port分别是代理的地址和代理的端口;三是"SOCKS socksaddr:port",其中socksaddr和port分别是socks代理的地址和端口,一个自动代理文件可以是多个选择的组合,其中用分号(;)隔开,如:
function FindProxyForURL(url,host)
{
if (host == "www.mydomain.com")
return "DIRECT";
return "PROXY myproxy:80;
PROXY myotherproxy:8080;
DIRECT";
}

下面是代理脚本可能用到的函数和说明(英文不好的朋友可以直接跳过去看应用):
PAC Helper Functions
dnsDomainIs(host, domain) Returns true if the host is part of the specified domain, false otherwise.
isInNet(hostname, Resolves the hostname and subnet IP, subnet mask) returns true if the hostname is within the subnet
specified by the IP address and the subnet mask, false otherwise.
isPlainHostName(host) Returns true if there are no dots in the hostname, false otherwise.
isResolvable(host) Internet Explorer tries to resolve the hostname through DNS and returns true if successful, false otherwise.
localHostOrDomainIs Returns true if the host matches (host, domain) the host portion of the domain, or if the host matches the host and domain portions of the domain, false otherwise. (Executed only for URLs in the local domain.)
dnsDomainLevels(host) Returns the number of dots in the hostname.
dnsResolve(host) Returns a string containing the IP address of the specified host.
myIPAddress( ) Returns a string containing the local machine's IP address.
shExpMatch(url, shexp) Returns true if the supplied URL matches the specified shell expression, false otherwise.
dateRange(parmList) Returns true if the current date falls within the dates specified in parmList, false otherwise.
timeRange(parmList) Returns true if the current time falls within the times specified in parmList, false otherwise.
weekdayRange(parmList) Returns true if today is within the days of the week specified in parmList, false otherwise.

下面是各个函数应用的例子:
作者: xmudahai

2 自动配置脚本文件的写法与用途(原创)
a、isPlainHostName(host),本例演示判断是否为本地主机,如 http://myservername/
的方式访问,如果是直接连接,否则使用代理
function FindProxyForURL(url, host)
{
if (isPlainHostName(host))
return "DIRECT";
else
return "PROXY proxy:80";
}
b、dnsDomainIs(host, "")、localHostOrDomainIs(host, ""),本例演示判断访问主机是否属于某个域和某个域名,如果属于.company.com域的主机名,而域名不是company.com和home.company.com的直接连接,否则使用代理访问。
function FindProxyForURL(url, host)
{
if ((isPlainHostName(host) ││
dnsDomainIs(host, ".company.com")) &&
!localHostOrDomainIs(host, "www.company.com") &&
!localHostOrDomainIs(host, "home.company.com"))
return "DIRECT";
else
return "PROXY proxy:80";
}
c、isResolvable(host),本例演示主机名能否被dns服务器解析,如果能直接访问,否则就通过代理访问。
function FindProxyForURL(url, host)
{
if (isResolvable(host))
return "DIRECT";
else
return "PROXY proxy:80";
}
d、isInNet(host, "", ""),本例演示访问IP是否在某个子网内,如果是就直接访问,否则就通过代理,例子演示访问清华IP段的主页不用代理。
function FindProxyForURL(url, host)
{
if (isInNet(host, "166.111.0.0", "255.255.0.0"))
return "DIRECT";
else
return "PROXY proxy:80";
}
e、shExpMatch(host, ""),本例演示根据主机域名来改变连接类型,本地主机、*.edu 、*.com分别用不同的连接方式。
function FindProxyForURL(url, host)
{
if (isPlainHostName(host))
return "DIRECT";
else if (shExpMatch(host, "*.com"))
return "PROXY comproxy:80";
else if (shExpMatch(host, "*.edu"))
return "PROXY eduproxy:80";
else
return "PROXY proxy:80";
}
f、url.substring(),本例演示根据不同的协议来选择不同的代理,http、https、ftp、gopher分别使用不同的代理。
function FindProxyForURL(url, host)
{
if (url.substring(0, 5) == "http:") {
return "PROXY proxy:80";
}
else if (url.substring(0, 4) == "ftp:") {
return "PROXY fproxy:80";
}
else if (url.substring(0, 7) == "gopher:") {
return "PROXY gproxy";
}
else if (url.substring(0, 6) == "https:") {
return "PROXY secproxy:8080";
}
else {
return "DIRECT";
}
}
g、dnsResolve(host),本例演示判断访问主机是否某个IP,如果是就使用代理,否则直接连接。
unction FindProxyForURL(url, host)
{
if (dnsResolve(host) == "166.111.8.237") {
return "PROXY secproxy:8080";
}
else {
return "PROXY proxy:80";
}
}
h、myIpAddress(),本例演示判断本地IP是否某个IP,如果是就使用代理,否则直接使用连接。
function FindProxyForURL(url, host)
{
if (myIpAddress() == "166.111.8.238") {
return "PROXY proxy:80";
}
else {
return "DIRECT";
}
}
i、dnsDomainLevels(host),本例演示访问主机的域名级数是几级,就是域名有几个点如果域名中有点,就通过代理访问,否则直接连接。
function FindProxyForURL(url, host)
{
if (dnsDomainLevels(host) > 0) { // if number of dots in host > 0
return "PROXY proxy:80";
}
return "DIRECT";
}
j、weekdayRange(),本例演示当前日期的范围来改变使用代理,如果是GMT时间周三到周六,使用代理连接,否则直接连接。
function FindProxyForURL(url, host)
{
if(weekdayRange("WED", "SAT", "GMT"))
return "PROXY proxy:80";
else
return "DIRECT";
}
k、最后一个例子是演示随机使用代理,这样可以好好利用代理服务器。
function FindProxyForURL(url,host)
{
return randomProxy();
}
function randomProxy()
{
switch( Math.floor( Math.random() * 5 ) )
{
case 0:
return "PROXY proxy1:80";
break;
case 1:
return "PROXY proxy2:80";
break;
case 2:
return "PROXY proxy3:80";
break;
case 3:
return "PROXY proxy4:80";
break;
case 4:
return "PROXY proxy5:80";
break;
}
}
利用上面的函数和例子说明,大家就可以写出比较复杂有效的自动代理脚本。

从手机浏览器访问《生活宝典》

站内搜索
  • PHP脚本语言存在安全漏洞
  • 代理配置脚本
  • Internet Explorer 可以阻止跨站脚本
  • 代理配置 脚本
  • 微商帮
    世界网站大全
    中国科研团队:大象的长鼻子是如何越变越长了
    中国科研团队:大象的长
    自己是否能够像自己想的那样做成一件事,身旁人的判断会比自己准确
    自己是否能够像自己想
    火宫殿:吃喝玩乐看,烧香拜神佛,红火的庙会经济
    火宫殿:吃喝玩乐看,烧香
    眼见为实也不为实,更须谨慎看到的并非全貌
    眼见为实也不为实,更须