Search results for 'setTime'. 1 post(s) found.

  1. 2007/08/29 Javascript & Cookie based Visitor Application
2007/08/29 08:24

Javascript & Cookie based Visitor Application


This Cookies records how many times the Visitor has visited the page and writes to the page accordingly.

visits.js
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 = (argc > 2) ? argv[2] : null;
  var path = (argc > 3) ? argv[3] : null;
  var domain = (argc > 4) ? argv[4] : null;
  var secure = (argc > 5) ? 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 DeleteCookie (name) {
  var exp = new Date();
  exp.setTime (exp.getTime() - 1);
  var cval = GetCookie (name);
  document.Cookie = name   "="   cval   "; expires="   exp.toGMTString();
}

var expDays = 30;
var exp = new Date();
exp.setTime(exp.getTime()   (expDays*24*60*60*1000));

function amt(){
  var count = GetCookie('count')
  if(count == null) {
    SetCookie('count','1')
    return 1
    }
    else {
    var newcount = parseInt(count)   1;
    DeleteCookie('count')
    SetCookie('count',newcount,exp)
    return count
  }
}

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

function printOut() {
  document.write("You've been here <b>"   amt()   "</b> times.");
}

Visitor_test.html
<html>
<head>
  <title>KURAPA.COM Visitor Test</title>
  <script type="text/javascript" src="visits.js"></script>
</head>

<body>
<script type="text/javascript">
<!--
  printOut()
//-->
</script>

Trackback 4 Comment 0

Trackback : Cannot send a trackbact to this post.

  1. Subject Free vintage porn galleries.

    Tracked from Free porn clips. 2008/12/29 00:10 delete

    Free porn video. Free online porn games. Totally free porn. Free porn samples.

  2. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 00:59 delete

    moneyideas

  3. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 09:16 delete

    moneyideas

  4. Subject different money making ideas

    Tracked from moneyideas 2010/01/31 16:44 delete

    moneyideas