<html>
<head>
<title>Untitled Document</title>
<META content="text/html; charset=gb2312" http-equiv=Content-Type>
<meta http-equiv='pragma' content='no-cache'>
</head>
<script language="VBScript">
dim id
sub window_onload()
setInterval "DownXml",1000
end subsub DownXml()
dim xmlobj,NumRnd
randomize
NumRnd=100000*rnd+1
set xmlobj=createobject("Microsoft.XMLHTTP")
xmlobj.open "GET","myxml.asp?view=1",false
xmlobj.send
top.mainFrame.document.write(xmlobj.status&"-")
top.mainFrame.document.write(xmlobj.statusText)
set xmldom=xmlobj.responseXml
set objnode=xmldom.documentElement.childNodes
top.mainframe.document.write("<table>")
for i=0 to objnode.length-1
top.mainFrame.document.write("<tr><td>"&objnode.item(i).nodename&"</td>")
top.mainFrame.document.write("<td>"&objnode.item(i).text&"</td></tr>")
if objnode.item(i).nodename="id" then
id=objnode.item(i).text
end if
next
top.mainFrame.document.write("</table>")
set xmlobj=nothing
set xmldom=nothing
set objnode=nothing
end sub
</script>
<body>
myxml.asp文件中必需是输出XML格式文档,如:
也可以使用setInterval结合xml无刷新通知,下面是一段示例代码。myxml.asp文件中检查部门经理是否有新的文件。
<iframe name="mainFrame" src="about:blank"></iframe>
</body>
</html>
<%
response.ContentType="text/xml"
response.Expires=0
response.Write("<?xml version=""1.0"" encoding=""gb2312""?>")&vbcrlf
response.write("<msg><file><filename>新文件</filename></file></msg>")
%>