Tuesday 10 July 2012

Counter

To create your own personal visit counter, copy the cookie function script from the functions page and paste it in the <HEAD>...</HEAD> portion of your HTML document. Once you do that, you can embed a script that employs the universal cookie functions in your document. Take a look at the following script:
<SCRIPT>
var visits = getCookie("counter");
if (visits) {
     visits = parseInt(visits) + 1;
     document.write("By the way, you have been here " + visits + " times.");
}
else {
     visits = 1;
     document.write("By the way, this is your first time here.");
}
setCookie("counter", visits);
</SCRIPT>
Note that this script can be placed anywhere on the page. It prints the number of times the user has visited your site.

0 comments:

Post a Comment