The Hits method returns the number of times that a specified Web page has been opened.
oVar.Hits( [pathInfo] )
A LONG indicating the number of times that the specified Web page has been opened.
The following example uses the Hits method to display the number of times that the current Web page has been opened. This will be 0 if you have not used the PageHit method to increment the counter.
--- PageCounter_Hits.asp ---
<%
Set MyPageCounter = Server.CreateObject("MSWC.PageCounter")
Reset = Request.QueryString("Reset")
If Not "" = Reset Then
MyPageCounter.Reset
' or MyPageCounter.Reset([Path])
Response.Write "<H4>Reset Counter for " & Request.ServerVariables("PATH_INFO") & "</H4>"
End If
Hit = Request.QueryString("Hit")
If Not "" = Hit Then
MyPageCounter.PageHit
' or MyPageCounter.Reset([Path])
Response.Write "<H4>Incremented Counter for " & Request.ServerVariables("PATH_INFO") & "</H4>"
End If
%>
<P>
MyPageCounter.Hits = <%= MyPageCounter.Hits %>
<P>
If the address of this page is <B>http://localhost/pagecount_hits.asp</B> then<BR>
you could use MyPageCounter.Hits("/pagecount_hits.asp")
<P>
If the address of this page is <B>http://localhost/MyExamples/pagecount_hits.asp</B> then<BR>
you could use MyPageCounter.Hits("/MyExamples/pagecount_hits.asp")
<FORM NAME="ResetHitCounter" METHOD="GET" ACTION="PageCount_Hits.asp">
<INPUT TYPE="SUBMIT" NAME="Reset" VALUE="Reset Hit Counter">
<INPUT TYPE="SUBMIT" NAME="Hit" VALUE="Increment Hit Counter">
</FORM> If Cookie Then Response.Write "<TD><B>Cookie</TD>"