#12003/8/23 17:15:00
我有这段显示在线人数的代码!可是没次刷新页面很是不好!有没有什么好的办法呢?
让其在短时间内知道在线人数而不用刷新整个页面!谢谢各位高手指点
<%
dim refreshtime,idletime,totalusers,onlineuser(),tmp(),num,i,id
refreshtime=15
idletime=refreshtime*3
application.lock
if application(session.sessionid&"lastaccesstime")=empty then
if application("totalusers")=empty then application("totalusers=0")
redim tmp(application("totalusers")+1)
num=0
if application("totalusers")>0 then
for i=lbound(application("onlineuser")) to ubound(application("onlineuser"))
id=application("onlineuser")(i)
if id<>session.sessionid then
tmp(num)=id
num=num+1
end if
next
end if
tmp(num)=session.sessionid
application("totalusers")=num+1
redim preserve tmp(application("totalusers"))
application("onlineuser")=tmp
end if
application(session.sessionid&"lastaccesstime")=timer
redim tmp(application("totalusers"))
num=0
for i=0 to application("totalusers")-1
id=application("onlineuser")(i)
if (timer-application(id&"lastaccesstime"))tmp(num)=id
num=num+1
else
application(id&"lastaccesstime")=empty
end if
next
if num<>application("totalusers") then
redim preserve tmp(num)
application("onlineuser")=tmp
application("totalusers")=num
end if
application.unlock
%>
">
目前在线人数为:<%=application("totalusers")%>