海克斯康键槽的对称度:如何实现自动的刷新

来源:百度文库 编辑:查人人中国名人网 时间:2024/05/06 01:51:29
我想做到,当A机用户提交一个表单后,B机在进行刷新的操作情况下,页面即时显示,就像聊天室中用来滚动现实聊天内容的区域。

请提供参考代码或您知道的完整代码,谢谢!

网页:ASP+ACCESS,VB脚本!

显示内容页面

<script language="vbscript">
Function bytes2BSTR(vIn)
strReturn = ""
For i = 1 To LenB(vIn)
ThisCharCode = AscB(MidB(vIn,i,1))
If ThisCharCode < &H80 Then
strReturn = strReturn & Chr(ThisCharCode)
Else
NextCharCode = AscB(MidB(vIn,i+1,1))
strReturn = strReturn & Chr (CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
i = i + 1
End If
Next
bytes2BSTR = strReturn
End Function
sub loadmsg()
Set xmlHttp=CreateObject("Microsoft.XMLHTTP")
xmlhttp.Open "post", "response.asp" , false
xmlhttp.Send()
msg.innerHtml=bytes2BSTR(xmlhttp.responseBody)
timeoutid = setTimeout("loadmsg()",1000)
end sub
</script>

<body onLoad="loadmsg()">
<div id="msg"></div>
</body>

response.asp文件内容

这个文件只要读取数据库就行了的记录就可以了.显示内容页面会自动刷新

第一种方法:<body onload='setTimeout("location.reload()",1000)'>

1000是一秒,你可以自己设定.
第二种方法:在 <body> 与 </body> 之间加入:
<META http-equiv=refresh content="10;url=../index.htm">

第三种方法:<script>
function rl(){
document.location.reload()
}
setTimeout(rl,2000)
</script>
第四种方法:<meta http-equiv="refresh" content="200">

在B机需要打开的页面中加入下的内容:

<script language="javascript">
setInterval("location.reload();","1000");
</script>

祥解:
setInterval("","")的作用是在过一定的时间触发一个事件,第一个参数为触发事件的代码,第二个为时间间隔,单位为毫秒。

location.reload()的作用是重新载入页面,也就是“刷新”。