各位高手,我有个关于asp页面刷新的问题。送分答谢!

来源:百度知道 编辑:UC知道 时间:2024/05/08 19:47:37
各位高手:
请帮忙分析一下这个asp的页面刷新函数:

<%

'原始函数
Dim inteval
Dim LastRefreshTime

inteval=10 '设定刷新间隔为10秒钟

If application("LastRefreshTime")="" Then application("LastRefreshTime")=now()

LastRefreshTime=application("LastRefreshTime")

Do While datediff("s",LastRefreshTime,now())>=inteval
LastRefreshTime=dateadd("s",inteval,LastRefreshTime)
Loop

application("LastRefreshTime")=LastRefreshTime
'原始函数

%>

<meta http-equiv="refresh" content="<%=inteval-Datediff("s",LastRefreshTime,now())%>;url=test.asp">

我的分析:

函数是定义了定值inteval为十秒,然后使用application("LastRefreshTime")传递每次刷新时间。当时间差值datediff("s",LastRefreshTime,now())大于十秒循环,更新LastRefreshTime变量,再将这个新值传递给application("LastRefreshTime")。

我的问题:

这个本身没有太大的意义吧。
对了,我试了一下你的问题,不过你不太认真哟。
比如:每次刷新都是Datediff("s",LastRefreshTime,now()=0。
这句就是不正确的:我用下面的程序测试了一下,
<%
'原始函数
Dim inteval
Dim LastRefreshTime

inteval=10 '设定刷新间隔为10秒钟

If application("LastRefreshTime")="" Then application("LastRefreshTime")=now()'0 '如果当前的应用程序没有LastRefreshTime的话,就把当前的时间给它/
'值得说明的是: application("LastRefreshTime")中的LastRefreshTime和 LastRefreshTime变量是不一样的。

LastRefreshTime=application("LastRefreshTime") ' 然后把存在application("LastRefreshTime")中的值给LastRefreshTime变量。

Do While datediff("s",LastRefreshTime,now())>=inteval '当过了十秒以后,
LastRefreshTime=dateadd("s",inteval,LastRefreshTime) '就让LastRefreshTime的值加10秒。
Loop

application("LastRefreshTime")=LastRefreshTime '现把LastRefreshTime变量的新值给application("LastRefreshTime"