逐梦论坛's Archiver

shillan 发表于 2005-12-4 08:01

网速测试

<div style="line-height: 180%" align=left>
<p>代码存为speedtest.asp,同目录下放一个大约100k的img.jpg图片,具体大小请改代码中的<font class=hightlight>var fs = 137.57//img.jpg文件大小(k)</font></p>
<p><a href="http://www.51windows.net/asp_samples/speedtest.asp" target=_blank><font color=#0000ff>查看演示</font></a></p>
<p><textarea style="width: 100%; height: 300px" name=code rows=20 cols=72>&lt;html&gt;
&lt;head&gt;
&lt;title&gt;网站速度测试-51windows.net&lt;/title&gt;
&lt;meta http-equiv="content-type" content="text/html; charset=gb2312"&gt;
&lt;meta name="author" content="51windows,海娃,haiwa"&gt;
&lt;meta name="description" content="power by 51windows.net"&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;%
        response.expires=-1
        response.expiresabsolute=now()-1
        response.cachecontrol="no-cache"
        dim imgrandom
        randomize
        imgrandom = int(799999 * rnd + 200000)
%&gt;
&lt;script language="javascript"&gt;
window.status = "下载数据中..."
var st = new date()
&lt;/script&gt;
&lt;img src="img.jpg?id=&lt;%=imgrandom%&gt;" width=0 height=0 onerror = showerr() onload="showspeed();"&gt;
&lt;script language="javascript"&gt;
//海娃(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 = ("服务器时间为:&lt;%=now%&gt;,您在本站的下载速度为:"+calcspeed+" (k/秒)")
        window.status = "您在本站的下载速度为:"+calcspeed+" (k/秒)"
}
function showerr()
{
        showtxt.innerhtml = ("数据下载错误,请刷新重试")
        window.status = "数据下载错误,请刷新重试"
}
&lt;/script&gt;
&lt;button style="font-size:12px;width:80;height:19px;" onclick=location.href="speedtest.asp?&lt;%=imgrandom%&gt;"&gt;重新测试&lt;/button&gt;
&lt;span id=showtxt&gt;&lt;/span&gt;
&lt;/body&gt;
&lt;/html&gt;

</textarea></p></div>
<hr size=1>
<span id=actzone><input onclick=sendmail() type=button value=推荐本页给您的朋友!> <input onclick=copyurl() type=button value=复制本页地址></span>

yufeiimy 发表于 2006-1-5 14:58

[EM02]

页: [1]

Powered by Discuz! Archiver 7.2  © 2001-2009 Comsenz Inc.