网页测速,以及定时刷新

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>


<title>网页测速,以及定时刷新</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<script src="jquery-1.9.1.js" /></script>
<script type="text/javascript">
//定时两秒刷新一次
setInterval('sub()',2000);
function sub(){
$("#sub").click();
}
</script>
</head>
<body>
<a href=""></a>
测试网站连接速度:
<script language="javascript">
tim=1
setInterval("tim++",100)
b=1
var autourl=new Array()
autourl[1]="www.baidu.com"
autourl[2]="www.sina.com"
autourl[3]="www.qq.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 id='sub' 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>

posted @ 2014-12-15 16:51  萝卜白菜家族  阅读(414)  评论(0编辑  收藏  举报
     萝卜白菜家族QQ