Whistling in the wind
am 31.12.2006 04:21:04 von Trevor_L.This is a multi-part message in MIME format.
------=_NextPart_000_1C37_01C72CE6.E7BEF460
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
The subject says it, I think.
I have a hit counter on my page below
The code is
Hit Counter:
where '_fpclass/hit_count.inc' is
<%
'Dimension variables
Dim fsoObject 'File System Object
Dim filObject 'File Object
Dim tsObject 'Text Stream Object
Dim lngVisitorNumber 'Holds the visitor number
Dim intWriteDigitLoopCount 'Loop counter to display the graphical hit count
Dim cntDigit 'Holds the digit displayed in the counter
'Create a File System Object variable
Set fsoObject = Server.CreateObject("Scripting.FileSystemObject")
'Initialise a File Object with the path and name of text file to open
Set filObject = fsoObject.GetFile(Server.MapPath("_private/index.asp.cnt"))
'Open the visitor counter text file
Set tsObject = filObject.OpenAsTextStream
'Read in the visitor number from the visitor counter file
lngVisitorNumber = CLng(tsObject.ReadAll)
'Increment the visitor counter number by 1
lngVisitorNumber = lngVisitorNumber + 1
'Create a new visitor counter text file over writing the previous one
Set tsObject =
fsoObject.CreateTextFile(Server.MapPath("_private/index.asp. cnt"))
'Write the new visitor number to the text file
tsObject.Write CStr(lngVisitorNumber)
'Reset server objects
Set fsoObject = Nothing
Set filObject = Nothing
Set tsObject = Nothing
'Display the hit count as text
' Response.Write(lngVisitorNumber)
'Loop to display graphical digits
For intWriteDigitLoopCount = 1 to Len(lngVisitorNumber)
' Display the graphical hit count
cntDigit = Mid(lngVisitorNumber, intWriteDigitLoopCount, 1)
Response.Write("
Response.Write(cntDigit & ".gif""")
Response.Write(" alt=""" & cntDigit & """>")
Next
%>
What I am wondering is:
Why does the count increment by 3 every time I visit the Guestbook and then
return to the Home Page ?
The Guestbook button is
/>
Guestbook
Even clicking Home increments it by 2
The Home button is
Home
Visiting my other web site and then returning does the same thing
(increments it by 2).
This button is
Trevor and Carole's
Home Page
Is there some way I can only increment the counter when the site
(http://trevorl.mvps.org/) is visited for the first time?
And going to somewhere else and then returning will not increment it?
--
Cheers,
Trevor L.
[ Microsoft MVP - FrontPage ]
MVPS Website: http://trevorl.mvps.org/
----------------------------------------
------=_NextPart_000_1C37_01C72CE6.E7BEF460
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
charset=3Diso-8859-1">
think.
below
</b><!--#include=20
file=3D'_fpclass/hit_count.inc'-->
where '_fpclass/hit_count.inc'=20
is
'Dimension variables
Dim=20
fsoObject &nbs=
p; =20
'File System Object
Dim=20
filObject &nbs=
p; =20
'File Object
Dim=20
tsObject  =
; =20
'Text Stream Object
Dim =
lngVisitorNumber =20
'Holds the visitor number
Dim intWriteDigitLoopCount 'Loop =
counter=20
to display the graphical hit count
Dim=20
cntDigit 'Holds the digit displayed in the=20
counter
variable
Set=20
fsoObject =3D =
Server.CreateObject("Scripting.FileSystemObject")
and name of=20
text file to open
Set filObject =
fsoObject.GetFile(Server.MapPath("_private/index.asp.cnt"))
file
Set tsObject=20
=3D filObject.OpenAsTextStream
visitor=20
counter file
lngVisitorNumber =3D CLng(tsObject.ReadAll)
by=20
1
lngVisitorNumber =3D lngVisitorNumber + 1
over=20
writing the previous one
Set tsObject =
fsoObject.CreateTextFile(Server.MapPath("_private/index.asp. cnt"))=
text=20
file
tsObject.Write CStr(lngVisitorNumber)
Set fsoObject =
=
Nothing
Set filObject =3D Nothing
Set tsObject =3D =
Nothing
text
' Response.Write(lngVisitorNumber)
digits
For=20
intWriteDigitLoopCount =3D 1 to Len(lngVisitorNumber)
' Display =
the=20
graphical hit count
cntDigit =3D Mid(lngVisitorNumber,=20
intWriteDigitLoopCount, 1)
Response.Write("<img=20
src=3D""counter_images/")
Response.Write(cntDigit &=20
".gif""")
Response.Write(" alt=3D""" & cntDigit &=20
""">")
Next
%>
time I=20
visit the Guestbook and then return to the Home Page ?
is
=
<img=20
src=3D"images/display/guestbook-icon1.gif" alt=3D"Guestbook" =
height=3D"40" /><br=20
/>
Guestbook</a>
by=20
2
target=3D"_self">
=20
<img src=3D"images/display/sitehome.gif" alt=3D"Home" =
/><br=20
/>
Home</a>
returning does=20
the same thing (increments it by 2).
>
=20
<img src=3D"images/display/trevor-and-carole.gif" =
alt=3D"T&C"=20
/><br />
Trevor and Carole's<br />Home=20
Page</a>
the counter=20
when the site ( href=3D"http://trevorl.mvps.org/">http://trevorl.mvps.org/) is =
visited for the=20
first time?
then returning=20
will not increment it?
--
Cheers,
Trevor L.
[ Microsoft MVP - FrontPage =
]
MVPS=20
Website: href=3D"http://trevorl.mvps.org/">http://trevorl.mvps.org/
-------=
---------------------------------
------=_NextPart_000_1C37_01C72CE6.E7BEF460--