Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Client Side Web Counter 1

Status
Not open for further replies.

cdbillups

IS-IT--Management
Jan 3, 2002
30
US
Is there a counter that is completely client side? I'm developing an internal site and want to have the counter contained on my site. I don't want to have to place a file on the server in a certain directory to get it to work. Is there some type of java/cgi/perl code that can do this? I'm not real familiar with any of those so detailed instructions would be helpful. Thanks.
 
cannot be client side unless you want the clients visit count only. the concept is that the counter adds one to itself when it finds the "server" is reached. individual machines can count how many times that individual machine has visited the site by using cookies Ranjan
I earn because I learn
 
Sounds to me like a job for asp.

Here is the counter I use on our sites:

Obviously this has to go at the top of the page above all code:
<%@LANGUAGE=&quot;VBSCRIPT&quot;%>

This is the code for the counter insert it on the page where you want the counter, you can also surround it with font tags to adjust the look:
<%
set fso = createobject(&quot;scripting.filesystemobject&quot;)
set act = fso.opentextfile(server.mappath(&quot;counter.txt&quot;))
counter = clng(act.readline)
if session(&quot;been_here_before&quot;) = &quot;&quot; then
session(&quot;been_here_before&quot;) = &quot;Yes&quot;
counter = counter + 1
Set act = fso.CreateTextFile(server.mappath(&quot;counter.txt&quot;), true)
act.WriteLine(counter)
end if
act.Close
Response.Write counter
%>

Then all you need to do is create a text file named counter.txt with a number 1 on the first line of the file. Upload the txt file into the root that the page with the counter is in and that's it. If you are not on a server that can run asp then it won't work obviously. I like this counter method because it only counts the user once per session, you will notice that unless you close your browser, reopen it and go back to your site, it only counts you once regardless of hitting refresh. This is why I have it on every page, so that no matter what entry point the access on the site it counts them.

-
radium.gif

Looking Toward The Future
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top