利用JS測試目標網(wǎng)站的打開響應速度
更新時間:2017年12月01日 15:10:38 投稿:wdc
本文簡單說明利用JS來測試目標網(wǎng)站的打開響應速度,方法簡單明了大家一看就明白并附上了腳本源碼
閑來無事,用JS寫了一個簡單的測試目錄網(wǎng)站打開速度的小東西,注意這個只是本機打開目錄網(wǎng)站的速度,不代表其它用戶的打開也是這個速度,實際上也可用于測試本地網(wǎng)絡速度
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>test</title>
</head>
<body bgcolor="transparent" style="color:#FFFFFF;">
<style type="text/css">
input{font-size:12px;padding:0 5px;line-height:21px; font-family:tahoma;border:1px solid #ccc;height:21px;} </style>
<script language="javascript">
tim=1
setInterval("tim++",100)
b=1
var autourl = new Array();
autourl[1] = "www.qq.com";
autourl[2] = "www.dbjr.com.cn";
autourl[3] = "www.baidu.com";
autourl[4] = "www.sina.com";
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=url
if(tim>200)
{document.forms[0]["txt"+b].value="網(wǎng)址"+b+"鏈接超時"}
else
{ document.forms[0]["txt" + b].value = "網(wǎng)址" + 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>
每臺電腦所在的網(wǎng)絡環(huán)境都很復雜,所以這個腳本得出的值只做參考。
相關文章
jQuery?事件綁定及取消?bind?live?delegate?on?one區(qū)別解析
這篇文章主要介紹了jquery?事件綁定及取消?bind?live?delegate?on?one區(qū)別解析,本文給大家講解的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下2022-11-11
JavaScript對象訪問器Getter及Setter原理解析
這篇文章主要介紹了JavaScript對象訪問器Getter及Setter原理解析,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下2020-12-12
Electron去掉窗口邊框并添加關閉按鈕的實現(xiàn)步驟
在?Electron?中,如果你想去掉默認的窗口邊框(frame)并添加額外的按鍵,可以通過相關步驟實現(xiàn),下面小編給大家?guī)砹薊lectron去掉窗口邊框并添加關閉按鈕的實現(xiàn)步驟,感興趣的朋友一起看看吧2024-06-06
layui點擊左側導航欄,實現(xiàn)不刷新整個頁面,只刷新局部的方法
今天小編就為大家分享一篇layui點擊左側導航欄,實現(xiàn)不刷新整個頁面,只刷新局部的方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-09-09

