shillan 当前离线
瞌睡虫
管理员
代码存为speedtest.asp,同目录下放一个大约100k的img.jpg图片,具体大小请改代码中的var fs = 137.57//img.jpg文件大小(k)
查看演示
<html> <head> <title>网站速度测试-51windows.net</title> <meta http-equiv="content-type" content="text/html; charset=gb2312"> <meta name="author" content="51windows,海娃,haiwa"> <meta name="description" content="power by 51windows.net"> </head> <body> <% response.expires=-1 response.expiresabsolute=now()-1 response.cachecontrol="no-cache" dim imgrandom randomize imgrandom = int(799999 * rnd + 200000) %> <script language="javascript"> window.status = "下载数据中..." var st = new date() </script> <img src="img.jpg?id=<%=imgrandom%>" width=0 height=0 onerror = showerr() onload="showspeed();"> <script language="javascript"> //海娃(51windows.net) function showspeed() { var fs = 137.57 //img.jpg文件大小(k) var l = 2 //小数点的位数 var et = new date() alltime = fs*1000/(et - st) lnum = math.pow(10,l) calcspeed = math.round(alltime*lnum)/lnum showtxt.innerhtml = ("服务器时间为:<%=now%>,您在本站的下载速度为:"+calcspeed+" (k/秒)") window.status = "您在本站的下载速度为:"+calcspeed+" (k/秒)" } function showerr() { showtxt.innerhtml = ("数据下载错误,请刷新重试") window.status = "数据下载错误,请刷新重试" } </script> <button style="font-size:12px;width:80;height:19px;" onclick=location.href="speedtest.asp?<%=imgrandom%>">重新测试</button> <span id=showtxt></span> </body> </html>
yufeiimy 当前离线
新手上路
TOP
逐梦网|逐梦论坛 |联系我们 |Archiver|WAP|
GMT+8, 2024-11-24 09:11, Processed in 0.014488 second(s), 5 queries, Gzip enabled.
Powered by Discuz! 7.2 论坛QQ群:
© 2001-2021 Comsenz Inc. 鲁公网安备 37120302000001号