今天看到一段比较有意思的JS脚本,根据访问速度来选择镜像。

<script>
i
=1
var autourl=new Array()
autourl[
1]="http://bbs.hidotnet.com"
autourl[
2]="http://anf.hidotnet.com"
function choose(url)
{
  
if(i){top.location=url;i=0}
}

function run()
{
  
for(var i=1;i<autourl.length;i++)
  document.write(
"<img src="+autourl[i]+" width=1 height=1 onerror=choose('"+autourl[i]+"')>")
}

run()
</script>


我在北方网通和南方电信测试过,切实有效果。

原文地址:https://www.cnblogs.com/LCX/p/355060.html