测速网址:
http://202.98.203.254/执行测试的代码页
http://202.98.203.254/Speed.aspx怎么把它移植过来呢?
我下载了speed.aspx页面但用不了,而且代码有乱码
请高手指教了

解决方案 »

  1.   

    测速的原理很简单,下载一个大数据块,记录下所用的时间就可计算出下载速度。
    你可以直接用上面的网址来测速,在你的页面里加上下面2句就行了:<iframe id="SpeedTest" name="SpeedTest" frameborder="1" width="280" height="48" noresize="noresize" scrolling="no" ></iframe><br />
    <a href="http://202.98.203.254/Speed.aspx" target="SpeedTest">开始网速测试</a>
    也可以把speed.aspx复制过来:(你看到的***不是乱码,是用来产生测试载荷的数据,产生的html文件约10M大小,分成100块,每一块大小约100K)<%@ Page Language="C#" %>
    <!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="Pragma" content="no-cach">
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <meta name="keywords" /><meta name="description" />
    <title>网速测试</title>
    <style>
    body { margin:0px; font-size:9pt; }
    a { color:black; text-decoration:none; }
    </style>
    <script language="javascript">
    var StartTime = null;
    var EndTime = null;
    function ShowProcess(p)
    {
    SpeedBar.style.width = (p*2) + "px";
    EndTime = new Date();
    var TS = EndTime - StartTime;
    var DownByte = p*100000;
    var Down = Math.round(DownByte/1024) + "KB";
    var Rate = DownByte*1000/TS;
    var DRate = Math.round(Rate/1024) + "<font color=\"Red\">KB/s</font>";
    var LRate = Math.round(((Rate*8)/1024),2) + "<font color=\"Red\">Kb/s</font>";
    ProcessBarMsg.innerHTML = p + "%";
    LineRate.innerHTML = "<b>" + LRate + "</b> = <b>" + DRate + "</b>";
    }
    </script>
    </head>
    <body>
    <div style="width:100%;" align="center">测试您的宽带连接速度</div>
    <div style="width:100%;" align="center">
    <span style="display:inline-block; font-size:1px; height:8px; width:200px; border:1px #EEF2FF solid; text-align:left;">
    <span style="display:inline-block; font-size:1px; height:8px; background-color:#BBCCEE; width:0px;" id="SpeedBar"></span>
    </span>&nbsp;
    <span style="display:inline-block; width:30px;" id="ProcessBarMsg"></span>
    </div>
    <div style="width:100%;" align="center">当前连接速度:<span style="display:inline-block;" id="LineRate"></span></div>
    <script language="javascript">
    SpeedBar = document.getElementById("SpeedBar");
    ProcessBarMsg = document.getElementById("ProcessBarMsg");
    LineRate = document.getElementById("LineRate");
    </script>
    <script language="javascript">StartTime = new Date();</script>
    <% string test=new string('*', 99930); %>
    <% for (int i=1; i<=100; i++) { %>
    <!--<%=test%>-->
    <script language="javascript">
    ShowProcess(<%=i%>);
    </script>
    <%}%>
    </body>
    </html>
      

  2.   

    首先谢谢三楼的高手了用你提供的代码,测试时,提示这里有问题
    <% string test=new string('*', 99930); %>