用XMLHTTP
======================
<Html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/Html; charset=gb2312">
<script language="JavaScript">
function getXML(URL) {
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
XMLhttp.Open("GET",URL, false);
try {
XMLhttp.Send();
var result = XMLhttp.status;
}
catch(e) {
return(false);
}
if(result==200) {
return(streamtochar(XMLhttp.responseBody));
}
var XMLhttp = null;
}
function streamtochar(StrStream)
{
var stream = new ActiveXObject("ADODB.Stream");
stream.type=1;
stream.Mode=3;
stream.Open() ;
stream.Write(StrStream);
stream.Position= 0;
stream.Type= 2;
stream.Charset="GB2312";
var result= stream.ReadText();
stream.Close();
stream = null;
return result;
}
function update()
{
//alert("頁面開始更新");
// document.body.innerHtml = getXML('b.ASP');
parent.mainframe.document.body.innerHtml = getXML('b.ASP');
}
setInterval("update()",1000)
</script>
</head>
<body>
</body>
</Html>
它的實現過程是這樣的:
該頁面是a.ASP;
用於刷新的頁面是b.ASP;
執行a.asp頁面時轉向b.asp,以便使b.ASP1秒刷新一次。