利用JS测试目标网站的打开响应速度

时间:2021-05-25

闲来无事,用JS写了一个简单的测试目录网站打开速度的小东西,注意这个只是本机打开目录网站的速度,不代表其它用户的打开也是这个速度,实际上也可用于测试本地网络速度

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://";function butt(){document.write("<form name=autof style='padding:0px; margin:0px;'>")for (var i = 1; i < autourl.length; i++) document.write("<input type=text name=txt" + i + " size=25 style='color:#999;' 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 onclick='window.location.reload()' type=submit value='刷新' style='margin-top:10px'></form>")}butt()function auto(url){document.forms[0]["url"+b].value=urlif(tim>200){document.forms[0]["txt"+b].value="网址"+b+"链接超时"}else{ document.forms[0]["txt" + b].value = "网址" + b + ": 访问速度" + tim * 10 + "ms" }b++}function run(){for(var i=1;i<autourl.length;i++)document.write("<img src="+autourl[i]+"/"+Math.random()+" width=1 height=1 onerror=auto('"+autourl[i]+"') style='display:none'>")}run()</script></body></html>

每台电脑所在的网络环境都很复杂,所以这个脚本得出的值只做参考。

声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。

相关文章