application| Statistics | online | The most common method is to use session, but the disadvantage is that there is no immediate response online (with timeout) and server resources (if there are 100 people online there are 100 sessions, think about 8) Last time (seems to be a long time) introduced a method of using application+cookies, but the implementation of some cumbersome and also to set a hidden from the Refresh page.
This method avoids the above malady, after practice, the effect is good (example: WWW. Atersoft. Com/bbs), as follows:
Assume index. HTM is a frames page that contains three frames for Id=left,id=top and Id=bottom
1, make a statistic page usernum. Asp
<p> Statistical data ... </p>
<%
User=request.querystring ("User")
If User=0 then ' if left the number of people-1
Application.Lock
Application ("num") =application ("num")-1
Application.UnLock
Response.Write "<script>self.close ();</script>"
ElseIf User=1 Then ' if entered then +1
Application.Lock
Application ("num") =application ("num") +1
Application.UnLock
End If
%>
2, in the Frame page as (INDEX. HTM) embedded Usernum. Asp
<body onbeforeunload= "window.open (' usernum.asp?user=0 ', ' num ', ' menubar=no ')" >
......
<iframe src= "usernum.asp?user=1" frameborder=0 width=0 height=0></iframe>
3, in the need to display the number of pages (assuming the left display) to add
<div id=num><%=application ("num")%></div>
4, set the need to update the data page (such as bottom)
Function TJ () {
Top.left.num.innerhtml=<%=application ("num")%>;
}
<body onload= "TJ ()" >
Over, this is just an example, the specific application can be flexible, in addition, why when leaving window. OPEN Usernum. Where's the ASP? Because if the same is put in ifrme, the window closes too fast, usernum. ASP page can be turned off when it is too late to reduce the number of people, deficiencies welcome to explore GWLX@21CN.COM