是不是有好幾個鏡像站點?是不是經常有的站點打不開?你是不是想讓網友自動進入一個最快的鏡像站點?相信這是困擾了許多個人網站站長的問題,現在終于有了個很好的解決辦法了......
方案一:
<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>
<font color=blue size=7> 請稍候,正在選擇速度最快站點......</p> <script> i=1 var autourl=new Array() autourl[1]="http://szyhbcn.y365.com"; autourl[2]="http://www.qxcomm.com/p_html/szyhbcn"; autourl[3]="http://free.yc365.com/szyhbcn"; //設置三個鏡像站點,當然你也可以多加幾個只要如上形式即可. 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]="szyhbcn.y365.com"
autourl[2]="www.qxcomm.com/p_html/szyhbcn"
autourl[3]="free.yc365.com/szyhbcn"
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>
|