知道各个服务器IP,客户端想在网站上实现测速,有点像证券行情或交易软件上的那种服务器测速,看哪个最快。不知道用ping能不能实现?用下面这种方法,测出来和实际不符合(快的花的时间反而比较长)。请问有没有哪位大师知道有其他更好的办法且准确的方法(注:一定要在网页上实现运行)或者像移动邮箱登录测速的那种代码实现。谁能解答下吗<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
</head> <body>
<script>
tim=1;
//每0.1s tim++
setInterval("tim++",100);
b=1;
//定义数组存放访问站点域名或IP
var autourl=new Array();
autourl[1]="125.46.92.51";
autourl[2]="222.73.228.210";
autourl[3]="58.251.39.41";
autourl[4]="218.18.103.38";
autourl[5]="210.22.9.241"; function butt(){
document.write("<form name=autof>");
//循环提交数据报头,进行HTTP请求
for(var i=1;i<autourl.length;i++) document.write("<input type=text name=url"+i+" size=40> <input type=text name=txt"+i+" size=10 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>
</body>
</html>
<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
</head> <body>
<script>
tim=1;
//每0.1s tim++
setInterval("tim++",100);
b=1;
//定义数组存放访问站点域名或IP
var autourl=new Array();
autourl[1]="125.46.92.51";
autourl[2]="222.73.228.210";
autourl[3]="58.251.39.41";
autourl[4]="218.18.103.38";
autourl[5]="210.22.9.241"; function butt(){
document.write("<form name=autof>");
//循环提交数据报头,进行HTTP请求
for(var i=1;i<autourl.length;i++) document.write("<input type=text name=url"+i+" size=40> <input type=text name=txt"+i+" size=10 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>
</body>
</html>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货