PDA

View Full Version : Javascript hit counter


Akujin
10-23-2002, 09:14 PM
I have been searching the net for a couple of days now trying to figure out a way to code a Hit Counter in Javascript. I can easily do this in Perl or ASP but i do not want to use a Perl or ASP page, i want my page to be in normal HTML format. The problem i run into is that i do not know how to access outside files in Javascript, so i can't just create a file with the number of hit in it and print that to the document.

Is there a way to edit and call from an external file in javascript that i don't know of? Or is there another way to write a hit counter in Javascript?

also, i don't want to use code from another website, i'd like to write this on my own so don't bother telling me to download a hit counter from another website.

If anyone can help with this i'd be glad to share my knowlege of whatever you wish in return.

Nightfire
10-23-2002, 09:39 PM
If you know serverside, then you should know you can't make javascript hit counter :p

joh6nn
10-24-2002, 01:51 AM
javascript can't access outside files.

Spookster
10-24-2002, 02:40 AM
Also if you know Perl you should know that you can write the counter program in Perl and generate a graphic file with the current count and use that as the source of the image tag just as most counter programs do. :)

Example:

<img src="http://www.statcounter.com/counter/counter.pl?&usr=dqueue">

Akujin
10-24-2002, 05:59 AM
as per that last message, i've tried it and it didn't work.

however i figured out that SSI works nicely for what i wanted

Spookster
10-24-2002, 06:06 AM
Well it does work obviously as most free web counter sites use perl with images in this manner and SSI is not required.