ASP实现网站速度测试的源码
下面的代码保存为.asp,并在该目录下入一个大约100k的图片img.jpg测速用
程序代码:
<HTML>
<HEAD>
<TITLE>网站速度测试-http://www.XFBBS.com</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</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 = 27.8 //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="speed.asp?<%=Imgrandom%>">重新测试</button>
<span id=showtxt></span>
</BODY>
</HTML>
【相关文章:】
用PHP实现网站广告轮播
用PHP实现网站验证码功能
如何用PHP实现网页动态跳转
PHP实现网页自动更新块
用ASP实现悄悄话的功能
利用ASP实现三个强大功能
asp实现k线图(在线)
用ASP实现对ORACLE数据库的操作
MD5不可逆加密算法的ASP实现实例
利用自己开发的vc组件结合asp实现网上实时搜索
【发表评论】【打印此文】【关闭窗口】【点击数: 】
