js测试网页连接速度

解决方案 »

  1.   

    <script>tim=1setInterval("tim++",100)b=1var autourl=new Array()autourl[1]="www.2ky.cn"autourl[2]="www.china.com"autourl[3]="www.sina.com.cn"autourl[4]="www.sohu.com"autourl[5]="www.cctv.com"function butt(){document.write("<form name=autof>")for(var i=1;i<autourl.length;i++)document.write("<input type=text name=txt"+i+" size=10 value=测试中……> =》<input type=text name=url"+i+" size=40> =》<input type=button value=GO onclick=window.open(this.form.url"+i+".value)><br>")document.write("<input type=submit value=刷新></form>")}butt()function auto(url){document.forms[0]["url"+b].value=urlif(tim>200){document.forms[0]["txt"+b].value="链接超时"}else{document.forms[0]["txt"+b].value="时间"+tim/10+"秒"}b++}function run(){for(var i=1;i<autourl.length;i++)document.write("<img src=http://"+autourl[i]+"/"+Math.random()+" width=1 height=1 onerror=auto('http://"+autourl[i]+"')>")}run()
    </script>
      

  2.   

    网上搜到的转载:(出处:http://bbs.blueidea.com/thread-2119914-1-1.html)
    <div align="center"> 
      <table width="700" height="356" border="0" align="center" cellpadding="0" cellspacing="0" background="images/jxbg.jpg">
        <tr> 
          <td width="202" height="303">&nbsp;</td>
          <td width="498"> <div align="center">
              <script>
    tim=1
    setInterval("tim++",100)
    b=1
    var autourl=new Array()
    autourl[1]="home.goofar.com/flash665"
    autourl[2]="ecw2.dhcn.net/kj/home/flash/"
    autourl[3]="liqiang665.91i.net"
    autourl[4]="lq2003.91i.net/main.asp"
    autourl[5]="home.goofar.com/lq2004"
    function butt(){
    document.write("<form name=autof>")
    for(var i=1;i<autourl.length;i++)document.write("<input type=text name=txt"+i+" size=10 value=测试中……> =》<input type=text name=url"+i+" size=40> =》<input type=button value=GO onclick=window.open(this.form.url"+i+".value)><br>")
    document.write("<input type=submit value=刷新></form>")
    }
    butt()
    function auto(url){
    document.forms[0]["url"+b].value=url
    if(tim>200)
    {document.forms[0]["txt"+b].value="链接超时"}
    else
    {document.forms[0]["txt"+b].value="时间"+tim/10+"秒"}
    b++
    }
    function run(){for(var i=1;i<autourl.length;i++)document.write("<img src=http://"+autourl[i]+"/"+Math.random()+" width=1 height=1 onerror=auto('http://"+autourl[i]+"')>")}
    run()
    </script>
            </div></td>
        </tr>
      </table>
    </div>