找回密码
 立即注册
查看: 1452|回复: 0

[JS]自动打开最快镜像站

[复制链接]

6802

主题

10

回帖

2万

积分

管理员

积分
21861
发表于 2019-5-20 20:50:43 | 显示全部楼层 |阅读模式
方案一:
<html>
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">
<meta http-equiv="refresh" content="5;url=./"> //设定检测的时间,每5秒刷新一次
<title>自动选择最快站点</title></head>
<center>
<p>
<br>
<font color=blue size=7><br>
请稍候,正在选择速度最快站点......</p>
<script>
i=1
var autourl=new Array()
autourl[1]="http://www.123cha.com";
autourl[2]="http://mir1.123cha.com";
autourl[3]="http://mir2.123cha.com"; //设置三个镜像站点,当然你也可以多加几个只要如上形式即可.
function auto(url) //设置一个自动转向的函数
{
if(i)
{
i=0;
top.location=url //设置新页面打开的形式
}}
function run() //设置一个启动函数
{
for(var i=1;
i<autourl.length;i++) //设置一个循环检测,检测最先打开的站点
document.write("<img src="+autourl+" width=1 height=1 onerror=auto('"+autourl+"')>" //写出具体的链接地址
}
run() //启动函数
</script>
</body></html>


方案二:
直接将下面代码加入到<body></body>中

<script>
i=1

var autourl=new Array()

autourl[1]="www.123cha.com"

autourl[2]="mir1.123cha.com"

autourl[3]="mir2.123cha.com"

function auto(url){if(i){i=0;top.location=url}}

function run(){for(var i=1;i<autourl.length;i++)document.write("<img src=http://"+autourl+" width=1 height=1 onerror=auto('http://"+autourl+"')>"}

run()
</script>
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表