今天发现一个多域名的跳转页,搭建在不同地区吧,然后可以自动跳转到最快的服务器。我一想,这个用途也挺多,比如我们需要给用户了解某些东西,我们要给用户智能分配最快的网址。再比如网站死了,跳转到正常网站等。我们的目的只有一个,让用户更快的访问网站。在这前提下,就需要这个跳转页了。
代码:
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta charset="utf-8">
<!--[if lte IE 9]>
<script type="text/javascript" src="./rs/js/json3.js"></script>
<![endif]-->
<script>
var speeds={};
var depend_urli={};
depend_urli['0']='cd';
speeds['cd']=0;
depend_urli['1']='cf';
speeds['cf']=0;
depend_urli['2']='58';
speeds['58']=0;
depend_urli['3']='mm';
speeds['mm']=0;
depend_urli['4']='oo';
speeds['oo']=0;
var base = new Date().getTime();
var fast = '<font style="color:red;font-weight:bolder;"> 最快!!</font>';
// http://nsc.lt168.us/
var srl = location.href;
var url = srl.split('//');
//url[0]=>http: OR https:
var http = url[0];
//url[1]=>nsc.lt168.us/
url = url[1].split('/');
//url[0]=>nsc.lt168.us
url = url[0]+'/';
//url=>nsc.lt168.us/
var temp = url.split('.');
//temp = array('nsc','lt168','us/');
var len = temp.length;
var l = 0;
switch(Number(len)){
// case 2+l: break;
case 2+l: break;
default: temp.shift(); break;
}
url = temp.join('.');
if(url.match(/nsc/)=='nsc'){
location.href = http+'//'+url+'index2.php';
}
var urls = new Array();
urls['0']='cd.'+url;
urls['1']='cf.'+url;
urls['2']='58.'+url;
urls['3']='mm.'+url;
urls['4']='oo.'+url;
if(http=='https:')
urls.shift();
function speed(obj,num,link){
var now = new Date().getTime();
var div = obj.parentNode;
speeds[depend_urli[num-1]]=now-base;
if(fast)
setTimeout("a("+num+",'"+link+"')",2000);
div.innerHTML = '<button onclick="a('+num+',\''+link+'\')">線路'+num+' : '+(now-base)+' ms '+fast+'</button>';
fast = '';
}
function a(n,url){
url = url||0;
var fm = document.getElementById("fm");
var lines = document.getElementById("lines");
var fline = document.getElementById("fline");
if(url){
fm.action = http+'//'+url+'index2.php';
lines.value=JSON.stringify(speeds);
fline.value=depend_urli[Number(n)-1];
fm.submit();
}
}
</script>
</head>
<body>
<form id="fm" method="post">
<input type="hidden" id="fline" name="fline">
<input type="hidden" id="lines" name="lines">
<script>
for(var i in urls){
i=Number(i);
document.write('<div><img src="http://'+urls[i]+'_index/speed.jpg?'+new Date().getTime()+'" style="cursor:pointer;display:none;" onload="speed(this,'+(i+1)+',\''+urls[i]+'\');"><button>線路'+(i+1)+' : loading </button></div>');
}
</script>
</form>
</body>
</html>
注意86行的图片是测速的关键,需要在网址对应的网址下添加一张图片,最好很小。
© 版权声明
THE END
暂无评论内容