<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>無標題頁</title>
</head>
代碼
<script type="text/javascript" >
var timeout = null; //setInterval函數控制代碼
var xmlHttp = false; //
function SendRequest()
{
//xmlHttp = false;
if (window.ActiveXObject)
{
try
{
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
}
else if (window.XMLHttpRequest)
{
xmlHttp = new XMLHttpRequest();
}
else
{
alert('初始化錯誤!');
return;
}
var url = "Handler.ashx";
//var url = "Default2.aspx";
xmlHttp.open("GET",url,true);
xmlHttp.onreadystatechange = ShowData;
xmlHttp.send(null);
}
function ShowData()
{
if(xmlHttp.readystate == 4)
{
if(xmlHttp.status == 200)
{
var tag = document.getElementById("container");
tag.innerHTML = "";
tag.innerHTML = xmlHttp.responseText;
}
}
}
//開始自動重新整理
function Update()
{
timeout = window.setInterval("SendRequest()", 1000);//設定1秒調用一次Default2.aspx頁面
}
//停止自動重新整理
function StopUpdate()
{
if (timeout != null)
{
window.clearInterval(timeout);
}
}
</script>
<body onload="SendRequest();">
<form id="form1" runat="server">
<div>
<input type="button" value="Start Fresh" onclick="Update();"/>
<input type="button" value="Stop Fresh" onclick="StopUpdate();"/>
<input id="Button1" type="button" value="確定" onclick="SendRequest();"/>
</div>
</form>
<div id="container"><!--容器--></div>
</body>
</html>