Hits

Hits 메서드는 지정된 웹 페이지가 열린 횟수를 반환합니다.

구문

oVar.Hits( [pathInfo] )

매개 변수

pathInfo

/virtualdirectoryname/filename.asp와 같은 형식을 사용하여 웹 페이지의 PATH_INFO를 지정하는 선택적 매개 변수입니다. 이 매개 변수를 지정하지 않으면 현재 페이지의 방문 횟수 카운트가 표시됩니다.

반환 값

지정된 웹 페이지가 열린 횟수를 나타내는 LONG 값입니다.

예제

다음은 Hits 메서드를 사용하여 현재 웹 페이지가 열린 횟수를 표시하는 예제입니다. 카운터를 늘릴 때 PageHit 메서드를 사용하지 않으면 이것은 0이 됩니다.

--- 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>"
 

관련 항목

Reset, PageHit


© 1997-2001 Microsoft Corporation. All rights reserved.