欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

js簡單網(wǎng)速測試方法完整實例

 更新時間:2015年12月15日 12:03:31   作者:bigwhiteshark  
這篇文章主要介紹了js簡單網(wǎng)速測試方法,以完整實例形式分析了JavaScript基于網(wǎng)頁圖片下載進行測試網(wǎng)速的實現(xiàn)技巧,需要的朋友可以參考下

本文實例講述了js簡單網(wǎng)速測試方法。分享給大家供大家參考,具體如下:

運行效果截圖如下:

具體代碼如下:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
 <title> New Document </title>
 <meta http-equiv="Content-Type" content="text/html; charset=gbk"/>
 <meta name="Generator" content="EditPlus">
 <meta name="Author" content="xinmingyang">
 <meta name="Keywords" content="">
 <meta name="Description" content="">
 </head>
 <body>
 <SCRIPT language=JavaScript>
   var st = new Date();
</SCRIPT>
<IMG alt="測試圖片" src="http://www.dbjr.com.cn/images/logo.gif" onload="showspeed();">
<div id='showtxt'></div>
<script>
  var arr=["網(wǎng)速低于50KB","網(wǎng)速在50-100KB之間","網(wǎng)速在100-200KB之間","網(wǎng)速在200-300KB之間","視頻通訊"];
  function showspeed() 
  { 
    var filesize =35.4;  //measured in KB  
    var et = new Date(); 
    var speed = Math.round(filesize*1000)/(et - st);
    document.title=speed;
    var scope=(speed>0 && speed<=50)?0:(speed>50 && speed<=100)?1:(speed>=100 && speed<200)?2:(speed>=200 && speed<300)?3:4;
    alert(scope)
    document.getElementById("showtxt").innerHTML = ("您的下載速度為:" + arr[scope] + " (K/秒)") 
  } 
</script>
 </body>
</html>

希望本文所述對大家JavaScript程序設計有所幫助。

相關文章

最新評論