Cookie Counter

[Total: 0    Average: 0/5]

This uses cookies to count visits to the page.

Head Code:

<SCRIPT>

<!---Activate Cloaking Device 
function WinOpen() 
   {
   alert('nPage will load to full screen.nnUse View/Document Source from menu bar to view source.nnClose new window to return to this page. ');
   window.open("/","DisplayWindow","menubar=yes");
   window.open("/","DisplayWindow","menubar=yes");   // double for Macs
   }


function leapto() 
   {
   window.location=window.location;
   }

function getCookieVal (offset) 
   {
   var endstr = document.cookie.indexOf (";", offset);
   if (endstr == -1)
      endstr = document.cookie.length;
   return unescape(document.cookie.substring(offset, endstr));
   }

function GetCookie (name) 
   {
   var arg = name + "=";
   var alen = arg.length;
   var clen = document.cookie.length;
   var i = 0;
   while (i < clen) 
      {
      var j = i + alen;
      if (document.cookie.substring(i, j) == arg)
         return getCookieVal (j);
      i = document.cookie.indexOf(" ", i) + 1;
      if (i == 0) 
         break; 
      }
   return null;
   }

function SetCookie (name, value) 
   {
   var argv = SetCookie.arguments;
   var argc = SetCookie.arguments.length;
   var expires = (2 < argc) ? argv[2] : null;
   var path = (3 < argc) ? argv[3] : null;
   var domain = (4 < argc) ? argv[4] : null;
   var secure = (5 < argc) ? argv[5] : false;
   document.cookie = name + "=" + escape (value) +
     ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
     ((path == null) ? "" : ("; path=" + path)) +
     ((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
   }

//  Function to reset counts

function ResetCounts(name) 
   {
   visits = 0;
   SetCookie("visits", visits, expdate , "/", null, false);
   leapto();
   }
// De-activate Cloaking -->
</Script>

Body Code:

<CENTER><STRONG><EM>
<FONT COLOR=0000FF SIZE=+5>B</FONT><FONT  COLOR=0000FF SIZE=+3>ROWSER    </FONT><FONT COLOR=0000FF SIZE=+5>C</FONT><FONT  COLOR=0000FF SIZE=+3>OUNTER</FONT>
</EM></STRONG></CENTER>
<HR WIDTH=370 ALIGN=center SIZE=2>
<BR><BR>

<Script>
<!-- Activate Cloaking 
var expdate = new Date();
var visits;

// Set expiration date to a year from now.
expdate.setTime(expdate.getTime() +  (24 * 60 * 60 * 1000 * 365)); 

if(!(visits = GetCookie("visits"))) 
   visits = 0;
visits++;
SetCookie("visits", visits, expdate, "/", null, false);

document.write("<center><STRONG>"+"Your browser has visited this page "+"</STRONG></center>" 
+"<FONT COLOR=0000FF><center><STRONG>"+visits+"</STRONG></center></FONT>"
+"<center><STRONG>"+"time(s)."+"</STRONG></center>");
   if(visits == 1) 
      document.write("<P><FONT SIZE=+2><EM><CENTER><STRONG><BLINK>"+" Welcome to my page!"                    +"</BLINK></STRONG></CENTER></EM></FONT>");
   if(visits == 2) 
      document.write("<P><FONT SIZE=+2><EM><CENTER><STRONG><BLINK>"+"I see you came back !"                    +"</BLINK></STRONG></CENTER></EM></FONT>");
   if(visits == 3) 
      document.write("<P><FONT SIZE=+2><EM><CENTER><STRONG><BLINK>"+"Oh, it's you again!"                           +"</BLINK></STRONG></CENTER></EM></FONT>");
   if(visits == 4) 
      document.write("<P><FONT SIZE=+2><EM><CENTER><STRONG><BLINK>"+"You must be curious!"                      +"</BLINK></STRONG></CENTER></EM></FONT>");
   if(visits == 5) 
      document.write("<P><FONT SIZE=+2><EM><CENTER><STRONG><BLINK>"+"You're practically a regular!"          +"</BLINK></STRONG></CENTER></EM></FONT>");
   if(visits == 6) 
      document.write("<P><FONT SIZE=+2><EM><CENTER><STRONG><BLINK>"+"You need a hobby!"                          +"</BLINK></STRONG></CENTER></EM></FONT>");
   if(visits == 7) 
      document.write("<P><FONT SIZE=+2><EM><CENTER><STRONG><BLINK>"+"Nothing better to do?"                      +"</BLINK></STRONG></CENTER></EM></FONT>");
   if(visits== 8) 
      document.write("<P><FONT SIZE=+2><EM><CENTER><STRONG><BLINK>"+"Don't you ever sleep?"                    +"</BLINK></STRONG></CENTER></EM></FONT>");
   if(visits== 9) 
      document.write("<P><FONT SIZE=+2><EM><CENTER><STRONG><BLINK>"+"Get a life!!!"                                  +"</BLINK></STRONG></CENTER></EM></FONT>");
   if(visits>=10) 
      document.write("<P><FONT SIZE=+2><EM><CENTER><STRONG><BLINK>"+"Rent is due on the 1st of the month!" +"</BLINK></STRONG></CENTER></EM></FONT>");
// De-activate Cloaking -->
</Script>

<BR>

<FORM>
<CENTER>
<TABLE BORDER=0 CELLSPACING=8 CELLPADDING=4 WIDTH=250>
<TR>
<TD align="center"><INPUT NAME="update" TYPE="BUTTON" VALUE="Revisit  Page" OnClick="leapto()"></TD>
<TD align="center"><INPUT NAME="reset" TYPE="BUTTON" VALUE="Reset Counter" OnClick="ResetCounts(visits)"></TD>
</TR>
</TABLE>
</CENTER></form>

Times Viewed: 3

Leave a Reply

Your email address will not be published. Required fields are marked *