スピードチェッカー

<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>Sample</title>
<link rel="stylesheet" href="main.css" type="text/css" media="all">
<script type="text/javascript" src="xmlhttp.js"></script>
<script type="text/javascript"><!--
urlList = [
"http://www.yahoo.co.jp/","http://www.openspc2.org/",
"http://www.google.co.jp/","http://www.apple.co.jp/",
"http://www.mycom.co.jp/","http://www.openspc.org/",
"http://www.microsoft.com/","http://www.newgameweb.com/",
"http://japan.cnet.com/"
];
function ajaxPing()
{
count = -1;
$("result").innerHTML = "";
readPageData();
}
function readPageData()
{
count++;
if (count < urlList.length)
{
xmlhttpObj = createXMLHttpRequest(displayStatus);
if (xmlhttpObj)
{
startTime = (new Date()).getTime();
var url = "curl.rb?sURL="+urlList[count]+"&cache="+startTime;
timeoutSec = parseInt($("sec").value);
xmlhttpObj.open("get",url,true);
xmlhttpObj.send(null);
timerID = setTimeout("httpTimeout()",timeoutSec*1000);
}
}else{
$("result").innerHTML += "完了";
}
}
function httpTimeout()
{
xmlhttpObj.abort();
$("result").innerHTML += msg = "[<span>NG</span>] "+urlList[count]+"<br>";
readPageData();
}
function displayStatus()
{
try {
if ((xmlhttpObj.readyState == 4) && (xmlhttpObj.status == 200))
{
clearTimeout(timerID);
var endTime = (new Date()).getTime();
var d = (endTime - startTime) / 1000;
if (d <timeoutSec)
{
$("result").innerHTML += "["+d+"msec] "+urlList[count]+"<br>";
}else{
$("result").innerHTML += msg = "[<span>NG</span>] "+urlList[count]+"<br>";
}
readPageData();
}
}catch(e){}
}
// --></script>
</head>
<body>
<img src="title.jpg">
<form onsubmit="ajaxPing();return false;">
<input type="button" id="sendBtn" value="読み込み" onClick="ajaxPing()">
 タイムアウト秒数:<input type="text" size="3" id="sec" value="5">
</form>
<div id="result"></div>
</body>
</html>
・サンプルを実行する
Ajax逆引きクイックリファレンス 説明などは本書を参考にしてください。