Search results for 'Javascript Cookie'. 9 post(s) found.

  1. 2007/09/07 Number Of Vists
  2. 2007/08/30 Address Book
  3. 2007/08/30 Greeting For The Time Of Day
  4. 2007/08/30 Access Granted
  5. 2007/08/30 Cookie enabled browser checking in Javascript
  6. 2007/08/30 Cookie Redirect (1)
  7. 2007/08/30 New content notifier in Javascript
  8. 2007/08/30 Let popup once for event dialog or something like that in Javascript
  9. 2007/08/30 Save And Restore Form Cookies in Javascript
2007/09/07 13:13

Number Of Vists


Get the Number Of Vists!

<script language="Javascript">
<!--
// please keep these lines on when you copy the source
// made by: Nicolas - http://www.javascript-page.com

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 = (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();
  FixCookieDate (exp); // Correct for Mac bug
  exp.setTime (exp.getTime() - 1);  // This Cookie is history
  var cval = GetCookie (name);
  if (cval != null)
    document.Cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}

var expdate = new Date();
var num_visits;
expdate.setTime(expdate.getTime() + (5*24*60*60*1000));
if (!(num_visits = GetCookie("num_visits")))
  num_visits = 0;
num_visits++;
SetCookie("num_visits",num_visits,expdate);
//-->
</script>

<script language="Javascript">
<!--
// please keep these lines on when you copy the source
// made by: Nicolas - http://www.geocities.com/ResearchTriangle/1500

document.write("You have been to this page "+num_visits+" times.");
//-->

</script>

Another posts included in "HTML, Javascript"

How to calculate page loading time ? (0)2007/09/07
Move window (0)2007/09/07
Is there URLEncode function in Javascript ? (0)2007/10/11
Add Message On Mouse Traling (0)2007/09/07
Tooltip (0)2007/09/07
Document Fader (0)2007/09/07
Book Mark This Site (0)2007/09/07
Icon Coupled Url (0)2007/09/07
Trackback 3 Comment 0

Trackback : Cannot send a trackbact to this post.

  1. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 04:13 delete

    moneyideas

  2. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 13:19 delete

    moneyideas

  3. Subject different money making ideas

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

    moneyideas

2007/08/30 08:40

Address Book


Saves an address book database as a Cookie on the user's computer. The author explains that although the actual example may not be particularly useful, the underlying code could be very beneficial for use in other projects.


<!-- TWO STEPS TO INSTALL ADDRESS BOOK:

  1.  Copy the coding into the HEAD of your HTML document
  2.  Add the last code into the BODY of your HTML document  -->

<!-- STEP ONE: Paste this code into the HEAD of your HTML document  -->

<HEAD>

<SCRIPT LANGUAGE="JavaScript">
<!-- Original:  Joe Norman (joe@wdrealty.com) -->
<!-- Web Site:  http://www.jacksonville.net/~joman/ArraysNCookies.html -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
var arrRecords = new Array();
var arrCookie = new Array();
var recCount = 0;
var strRecord="";
expireDate = new Date;
expireDate.setDate(expireDate.getDate()+365);
function cookieVal(CookieName) {
thisCookie = document.Cookie.split("; ")
for (i = 0; i < thisCookie.length; i++) {
if (CookieName == thisCookie[i].split("=")[0]) {
return thisCookie[i].split("=")[1];
   }
}
return 0;
}
function loadCookie() {
if(document.Cookie != "") {
arrRecords = cookieVal("Records").split(",");
currentRecord();
   }
}
function setRec() {
strRecord = "";
for(i = 0; i < document.frm1.elements.length; i++) {
strRecord = strRecord + document.frm1.elements[i].value + ":";
}
arrRecords[recCount] = strRecord;
document.frm2.add.value = "  NEW  ";
document.Cookie = "Records="+arrRecords+";expires=" + expireDate.toGMTString();
}
function newRec() {
switch (document.frm2.add.value) {
case "  NEW  " :
   varTemp = recCount;
   for(i = 0; i < document.frm1.elements.length; i++) {
   document.frm1.elements[i].value = ""
   }
   recCount = arrRecords.length;
   document.frm2.add.value = "CANCEL";
   break;
case "CANCEL" :
   recCount = varTemp;
   document.frm2.add.value = "  NEW  ";
   currentRecord();
   break;
   }
}
function countRecords() {
document.frm2.actual.value = "Record " + (recCount+1)+";  "+arrRecords.length+" saved records";
}
function delRec() {
arrRecords.splice(recCount,1);
navigate("previous");
setRec();
}
function currentRecord() {
if (arrRecords.length != "") {
strRecord = arrRecords[recCount];
currRecord = strRecord.split(":");
for(i = 0; i < document.frm1.elements.length; i++) {
document.frm1.elements[i].value = currRecord[i];
      }
   }
}
function navigate(control) {
switch (control) {
case "first" :
   recCount = 0;
   currentRecord();
   document.frm2.add.value = "  NEW  ";
   break;
case "last" :
   recCount = arrRecords.length - 1;
   currentRecord();
   document.frm2.add.value = "  NEW  ";
   break;
case "next" :
   if (recCount < arrRecords.length - 1) {
   recCount = recCount + 1;
   currentRecord();
   document.frm2.add.value = "  NEW  ";
   }
   break;
case "previous" :
   if (recCount > 0) {
   recCount = recCount - 1;
   currentRecord();
   }
   document.frm2.add.value = "  NEW  ";
   break;
   default:
   }
}

// Splice method Protype Function
// Peter Belesis, Internet.com
// http://www.dhtmlab.com/
 
if (!Array.prototype.splice)
{
  function array_splice(ind,cnt)
  {
    if (arguments.length == 0) return ind;
    if (typeof ind != "number") ind = 0;
    if (ind < 0) ind = Math.max(0,this.length + ind);
    if (ind > this.length)
    {
      if (arguments.length > 2) ind = this.length;
      else return [];
    }
    if (arguments.length < 2) cnt = this.length-ind;
    cnt = (typeof cnt == "number") ? Math.max(0,cnt) : 0;
    removeArray = this.slice(ind,ind+cnt);
    endArray = this.slice(ind+cnt);
    this.length = ind;
    for (var i = 2; i < arguments.length; i++)
    {
      this[this.length] = arguments[i];
    }
    for(var i = 0; i < endArray.length; i++)
    {
      this[this.length] = endArray[i];
    }
    return removeArray;
  }
  Array.prototype.splice = array_splice;
}
recCount = 0;
loadCookie();
countRecords();
//  End -->
</script>
</HEAD>

<!-- STEP TWO: Copy this code into the BODY of your HTML document  -->

<BODY>

<center>
<form name="frm1">
<table align="center" resize="none" border="0">
<tr>
<td align="right">Name:</td>
<td colspan="5"><input type="box" name="name" size="49"></td>
</tr>
<tr>
<td align="right">Address:</td><td colspan="5"><input type="box" name="address" size="49"></td></tr>
<td align="right">Address 2:</td><td colspan="5" align="left"><input type="box" name="address2" size="49"></td></tr>
<tr>
<td align="right">City:</td>
<td><input type="box" name="city" size="15"></td>
<td>State:</td><td><input type="box" name="state" size="15"></td>
<td>Zip:</td><td><input type="box" size="6" name="zip"></td>
</tr>
<td align="right">Phone:</td>
<td align="left"><input type="box" name="phone" size="15"></td>
<td align="right">Fax:</td><td align="left"><input type="box" name="fax" size="15"></td>
</tr>
<tr>
<td align="right">Web Page:<td colspan="5" align="left"><input type="box" name="address" size="49"></td></tr>
<td align="right">E-Mail:<td colspan="5" align="left"><input type="box" name="email" size="49"></td></tr>
<tr><td align="right" valign="top">Comments:</td>
<td colspan="5" align="left"><input type="box" name="comment1" size="49"><br>
<input type="box" name="comment2" size="49"><br>
<input type="box" name="comment3" size="49"><br>
<input type="box" name="comment4" size="49"><br>
<input type="box" name="comment5" size="49">
</td></tr></table>
</form>
<form name="frm2">
<table align="center" border="1" resize="none"><tr><td align="center">
<input type="button" name="first" value="|<<  " onClick="navigate('first');countRecords()">
<input type="button" name="previous" value="  <  " onClick="navigate('previous');countRecords()">
<input type="button" name="next" value="  >  " onClick="navigate('next');countRecords()">
<input type="button" name="last" value="  >>|" onClick="navigate('last');countRecords()">
<input type="box" name="actual" size=30></td></tr>
<tr><td align="center"><input type="button" name="add" value="  NEW  " onClick="newRec();countRecords()">
<input type="button" name="set" value="SAVE RECORD" onClick="setRec();countRecords()">
<input type="button" name="del" value="Delete" onClick="delRec();countRecords()"></td></tr></table>
</form>
</center>

<p><center>
<font face="arial, helvetica" size="-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>

<!-- Script Size:  6.01 KB -->

Trackback 3 Comment 0

Trackback : Cannot send a trackbact to this post.

  1. Subject different money making ideas

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

    moneyideas

  2. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 12:14 delete

    moneyideas

  3. Subject different money making ideas

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

    moneyideas

2007/08/30 08:36

Greeting For The Time Of Day


Displays a changeable greeting depending on the ""users system clock"".

<SCRIPT LANGUAGE="JavaScript">
<!-- Hide this script from old browsers --

var username = GetCookie('username');
if (username == null) {
username = prompt('Please enter your name or press cancel.',"");
 if (username == null) {
alert('It is OK that you don\'t want to share your name with us.');
username = 'Mr. No-Name';
  } else {
    pathname = location.pathname;
    myDomain = pathname.substring(0,pathname.lastIndexOf('/')) +'/';
    var largeExpDate = new Date ();
    largeExpDate.setTime(largeExpDate.getTime() + (30 * 24 * 3600 * 1000));
    SetCookie('username',username,largeExpDate,myDomain);
  }
}
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 = (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" : "");
}
var today = new Date ()
var hrs = today.getHours();
if (hrs < 5)
        document.write (" Morning <FONT COLOR=red>"+ username +", but shouldn't you be in bed, sleepy head");
else if (hrs < 12)
        document.write ("Morning <FONT COLOR=red>"+ username +"");
else if (hrs <= 18)
        document.write ("Afternoon <FONT COLOR=red>"+ username +"");
else
     document.write ("Evening <FONT COLOR=red>"+ username +""); 
if (hrs < 5) document.write("<FONT COLOR=red>?");
if (hrs > 5) document.write("<FONT COLOR=red>!");
document.writeln("<BR>");
// -- End Hiding Here -->
</SCRIPT>

Trackback 3 Comment 0

Trackback : Cannot send a trackbact to this post.

  1. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 04:29 delete

    moneyideas

  2. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 13:23 delete

    moneyideas

  3. Subject different money making ideas

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

    moneyideas

2007/08/30 08:34

Access Granted


Some details about the users browser and displays the number of times that the visitor has visited the page.

<SCRIPT LANGUAGE="JavaScript">
   function doCookie() {
       if(document.cookie) {
           index = document.cookie.indexOf("Cookie_Pages_02");
       } else {
           index = -1;
       }
       if (index == -1) {
           document.cookie="Cookie_Pages_02=1; expires=Tuesday, 01-Apr-1998 07:00:00 EST";
       } else {
           countbegin = (document.cookie.indexOf("=", index) + 1);
           countend = document.cookie.indexOf(";", index);
           if (countend == -1) {
               countend = document.cookie.length;
           }
           count = eval(document.cookie.substring(countbegin, countend)) + 1;
           document.cookie="Cookie_Pages_02="+count+"; expires=Tuesday, 01-Apr-1998 07:00:00 EST";
       }
   }
</SCRIPT></HEAD>
<BODY>
<SCRIPT LANGUAGE="JavaScript">
function gettimes() {
    if(document.cookie) {
        index = document.cookie.indexOf("Cookie_Pages_02");
        if (index != -1) {
            countbegin = (document.cookie.indexOf("=", index) + 1);
            countend = document.cookie.indexOf(";", index);
                if (countend == -1) {
                    countend = document.cookie.length;
                }
            count = document.cookie.substring(countbegin, countend);
            if (count == 1) {
                rating = "Newcomer"
                return (count+" <FONT FACE=ARIAL SIZE=2 COLOR=449977><B>time before.<br>User                                                                                                      Rating: "+rating);
            }
            else { if (count < 5) { rating = "Curiousity Fiend or Government Agent" }
                else { if (count < 12) { rating = "Mind Bender" }
                    else { if (count < 18) { rating = "Knowledge Seeker" }
                       else { if (count < 26) { rating = "Certifiably Hooked" }
                         else { if (count < 34) { rating = "Infonaut" }
                            else { if (count < 48 ) { rating = "Underground Connoisseur" }
                               else { if (count < 80 ) { rating = "Mischief Maker" }
                                  else { if (count < 100 ) { rating = "You're Your Own Daemon" }
                                     else { rating = "Devil's Info Advocate" }
                                    }
                                 }
                              }
                           }
                        }
                    }
                }
            }
            return (count+" <FONT FACE=ARIAL SIZE=2 COLOR=449977><B>times before.<br>Viewer Level: "+rating);
        }
    }
    return ("0 <FONT FACE=ARIAL SIZE=2 COLOR=449977><B>times before.<br>Rating: New ");
}
</SCRIPT></BODY>
<BODY
ONUNLOAD="doCookie()" BGCOLOR="#ffffff" TEXT="000000" LINK="449977" VLINK="449977">

<P><BR>
<BR>
</P>
<CENTER>
<SCRIPT LANGUAGE="JavaScript">
<!--
var where = document.referrer
var name = navigator.appName
var vers = navigator.appVersion
document.write("<FONT COLOR=449977 SIZE=2 FACE=ARIAL><B>Access Granted From "+where+" <BR>Via "+name+" "+vers+" ")
// -->
</SCRIPT>
</CENTER>
<P><BR>
</P>
<CENTER>
<SCRIPT>
    document.write("<FONT FACE=ARIAL SIZE=2 COLOR=449977><B>You Have Been Here "+gettimes());
</SCRIPT>

Trackback 3 Comment 0

Trackback : Cannot send a trackbact to this post.

  1. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 05:58 delete

    moneyideas

  2. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 14:32 delete

    moneyideas

  3. Subject different money making ideas

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

    moneyideas

2007/08/30 08:31

Cookie enabled browser checking in Javascript


This script checks to see if the user has Cookies enabled in his browser. If not,it displays an alert window letting them know your site is using Cookies.

if (navigator.cookieEnabled == 0) {
  alert("You need to enable cookies for this site to load properly!");
}

Trackback 3 Comment 0

Trackback : Cannot send a trackbact to this post.

  1. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 01:14 delete

    moneyideas

  2. Subject different money making ideas

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

    moneyideas

  3. Subject different money making ideas

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

    moneyideas

2007/08/30 08:29

Cookie Redirect


When a page has performed it's purpose,a Cookie can be set to redirect the browser to a different page on subsequent visits. Easily implemented. (Because it will redirect after one visit,the example is not shown on this site.)

CookieRedirect.js
/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: William Bontrager | http://www.bontragerconnection.com/ */
// Copyright 2006 Bontrager Connection,LLC
// This version of the script redirects automatically.
// The Web site has a few other methods for directing also:
// http://www.bontragerconnection.com/library/redirect_with_a_Cookie.shtml

// Three items can be customized (values between quotation marks):
//
// 1. What URL shall the browser be redirected
//    to if a Cookie was previously set?

var RedirectURL = "http://shamar.org";

// 2. How many days shall the Cookie live in
//    the visitor's browser (0 means remove
//    Cookie whenever browser closes)?

var DaysToLive = "365";

// 3. What name shall the Cookie have (any
//    sequence of alphabetical characters
//    is okay,so long as the name doesn't
//    conflict with any other Cookies that
//    this web page might be setting.)?

var CookieName = "HasVisited";

// No other customization is required.

function Action() {
location.href = RedirectURL;
}

DaysToLive = parseInt(DaysToLive);
var Value = 'bypass page next time';

function GetCookie() {
var Cookiecontent = '';
if(document.Cookie.length > 0) {
   var Cookiename = CookieName   '=';
   var Cookiebegin = document.Cookie.indexOf(Cookiename);
   var Cookieend = 0;
   if(Cookiebegin > -1) {
      Cookiebegin  = Cookiename.length;
      Cookieend = document.Cookie.indexOf(";",Cookiebegin);
      if(Cookieend < Cookiebegin) { Cookieend = document.Cookie.length; }
      Cookiecontent = document.Cookie.substring(Cookiebegin,Cookieend);
      }
   }
if(Cookiecontent.length > 0) { return true; }
return false;
}

function SetCookie() {
var exp = '';
if(DaysToLive > 0) {
   var now = new Date();
   then = now.getTime()   (DaysToLive * 24 * 60 * 60 * 1000);
   now.setTime(then);
   exp = '; expires='   now.toGMTString();
   }
document.Cookie = CookieName   '='   Value   exp;
return true;
}

if(GetCookie() == true) { Action(); }

SetCookie();

test.html
<script type="text/javascript" src="CookieRedirect.js"></script>

Trackback 3 1

Trackback : Cannot send a trackbact to this post.

  1. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 01:20 delete

    moneyideas

  2. Subject different money making ideas

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

    moneyideas

  3. Subject different money making ideas

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

    moneyideas

2007/08/30 08:25

New content notifier in Javascript


Use this Cookie to show your visitors what's new on your Web site since their last visit.

newYou.js
now = new Date
expireDate = new Date
expireDate.setMonth(expireDate.getMonth() 6)
lastVisit = new Date(cookieVal("pageVisit"))
document.Cookie = "pageVisit=" now ";expires="   expireDate.toGMTString()

function cookieVal(CookieName) {
  thisCookie = document.Cookie.split("; ")
    for (i=0; i<thisCookie.length; i  ) {
      if (CookieName == thisCookie[i].split("=")[0]) {
        return thisCookie[i].split("=")[1]
      }
    }
  return "1 January 1970"
}

function newCheck(yyy,mm,dd) {
  lastChgd = new Date(yyy,mm-1,dd)
  if (lastChgd.getTime() > lastVisit.getTime()) {
    document.write("<img src='/img/new-to-you/new.gif' alt='new'>")
  }
}


test.html
<html>
<head>
  <title>kurapa.com test</title>
  <script type="text/javascript" src="newYou.js"></script>
</head>
<body>
<script type="text/javascript" language="JavaScript"> newCheck(2005,2,11)</script> Be sure to check out our new scripts!
<br>
<script type="text/javascript" language="JavaScript"> newCheck(2005,2,3)</script> Have you seen our Tutorials?
</body>
</html>

Trackback 3 Comment 0

Trackback : Cannot send a trackbact to this post.

  1. Subject different money making ideas

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

    moneyideas

  2. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 08:23 delete

    moneyideas

  3. Subject different money making ideas

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

    moneyideas

2007/08/30 08:21

Let popup once for event dialog or something like that in Javascript


If you have a popup window which opens on your home page every time a visitor returns,it can become very annoying. Using Cookies,this script can determine if the visitor has been here before,and only open a new window on their first visit to the page. The next time they come back,the script will read the Cookie,identify them as a repeat visitor,and not open the window again.

onlyPopupOnce.js
var expDays = 1; // number of days the Cookie should last

var page = "only-popup-once.html";
var windowprops = "width=300,height=200,location=no,toolbar=no,menubar=no,scrollbars=no,resizable=yes";

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 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 checkCount() {
  var count = GetCookie('count');
  if (count == null) {
    count=1;
    SetCookie('count',count,exp);
    window.open(page,"",windowprops);
  } else {
    count  ;
    SetCookie('count',count,exp);
  }
}

window.onload=checkCount;


event_dialog.html
<html>
<head>
  <title>KURAPA.COM Event</title>
  <script type="text/javascript" src="onlyPopupOnce.js"></script>
</head>
<body>
.
.
.
</body>
</html>

Trackback 3 Comment 0

Trackback : Cannot send a trackbact to this post.

  1. Subject different money making ideas

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

    moneyideas

  2. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 08:36 delete

    moneyideas

  3. Subject different money making ideas

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

    moneyideas

2007/08/30 08:17

Save And Restore Form Cookies in Javascript


This script will save all of your form fields in a Cookie. It includes all text fields,radio button selections,checkbox values,etc. When your visitor returns,all form fields are automatically repopulated with the same value that they entered on their last visit.

formCookie_saverestore.js
// -----------------------------------------------------//
// SAVE FORM FIELD SELECTIONS IN Cookies         //
// formCookie_saverestore.js                //
// Written by Tony Davis,T. Davis Consulting,Inc.    //
// Date written: September 27,2005            //
// Email: tony@tdavisconsulting.com            //
// Web site: http://www.tdavisconsulting.com        //
// -----------------------------------------------------//

// instructions:
// ------------
// Change <BODY>
// to <BODY onunload="saveSelections(document.forms[0])"> and
// Change </FORM>
// TO </FORM><SCRIPT language=JavaScript type="">loadSelections(document.forms[0]);</SCRIPT>
// see a working example at: http://www.tdavisconsulting.com/formCookie
//

//
// ------------------------------------------------
// This function will concatentate all the fields in
// in the form into one string,delimited by a PIPE
// symbol,into one Cookie. The Cookie name is the
// same name as the form name. ALL fields are saved.
// ------------------------------------------------
//


function saveSelections(frm) {
        var setvalue;
        var fieldType;
        var index;
        var formname = frm.name;

        // Expire Cookie in 999 days.
        var today = new Date();
        var exp   = new Date(today.getTime() 999*24*60*60*1000);

        var string = "formname="   formname   "|";
        var CookieName = formname;

        //alert(exp);
        //alert(formname);

        var n = frm.length;
        for (i = 0; i < n; i  )

        {
            e         = frm[i].name;
            fieldValue  = frm[i].value;
            fieldType   = frm[i].type;

            //alert(e);
            //alert(fieldType);
            //alert(fieldValue);

            //
            // RADIO BUTTON
            //
            if (fieldType == "radio") {
            //alert(frm.elements[e].length);
                for (x=0; x < frm.elements[e].length; x  ) {
                    if (frm.elements[e][x].checked)
                    {
                    index = x
                    }
                }
            string = string   index   "\|";
            }

            //
            // TEXT,TEXTAREA,and DROPDOWN
            //
            if ((fieldType == "text") ||
                (fieldType == "textarea") ||
                (fieldType == "select-one"))
            {
                string = string   frm.elements[e].value   "\|";
                //alert("text");
            }

            //
            // CHECKBOX
            //
            if (fieldType == "checkbox")
            {
                if (frm.elements[e].checked==true) {
                    var setvalue = "1";
                    }
                if (frm.elements[e].checked==false) {
                    var setvalue = "0";
                    }
            string = string   setvalue   "\|";
            //alert("checkbox");
            }

            //
            // HIDDEN field
            //
            if (fieldType == "hidden")
            {
                string = string   frm.elements[e].value   "\|";
                //alert("text");
            }
        }

//alert(string);
setCookie(CookieName,string,exp); }

//
// LOAD FORM FIELD SELECTIONS FROM SAVED Cookies
//

function loadSelections(frm) {
var e;
var z;
var x;
var CookieName;
var fieldArray;
var fieldValues;
var fieldValue;

var formname = frm.id;

// Retrieve form elements from Cookie and split into array.

CookieName  = formname;
fieldValues = getCookie(CookieName);
fieldArray  = fieldValues.split("\|");

//alert(fieldArray);
//alert(fieldArray[0]);
//alert(fieldArray[1]);
//alert(fieldArray[2]);
//alert(fieldArray[3]);

        var n = frm.length;
        for (i = 0; i < n; i  ) {
            e = frm[i].name;
            z = i;
            z  ;
            var fieldType  = frm[i].type;
            var fieldValue = fieldArray[z];

            //
            // TEXT,TEXTAREA,and DROPDOWN
            //
            if ((fieldType == "text") ||
                (fieldType == "textarea") ||
                (fieldType == "select-one"))
            {
                frm.elements[e].value = fieldValue;
                //alert(e);
                //alert(fieldValue);
            }

            // CHECKBOX
            //
            if (fieldType == "checkbox")
            {
                fld_checkbox = fieldValue;
                if (fld_checkbox == "1") {
                    frm.elements[e].checked = true;
                }
            }

            // RADIO BUTTON
            //
            if (fieldType == "radio") {
                x = fieldValue;
                //alert(x);
                frm.elements[e][x].checked = true;
            }

            //
            // HIDDEN field
            //
            if (fieldType == "hidden")
            {
                frm.elements[e].value = fieldValue;
                }
        }
}

/// Cookie FUNCTIONS

function setCookie(name,value,expires,path,domain,secure) {
document.Cookie= name   "="   escape(value) 
((expires) ? "; expires="   expires.toGMTString() : "") 
((path) ? "; path="   path : "") 
((domain) ? "; domain="   domain : "") 
((secure) ? "; secure" : "");
}

function getCookie(name) {
var dc = document.Cookie;
var prefix = name   "=";
var begin = dc.indexOf("; "   prefix);
if (begin == -1) {
begin = dc.indexOf(prefix);
if (begin != 0) return null;
} else {
begin  = 2;
}
var end = document.Cookie.indexOf(";",begin);
if (end == -1) {
end = dc.length;
}
return unescape(dc.substring(begin   prefix.length,end));
}


test.html
.
.
.

<script type="text/javascript" src="formCookie_saverestore.js"></script>


.
.
.

Trackback 3 Comment 0

Trackback : Cannot send a trackbact to this post.

  1. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 05:02 delete

    moneyideas

  2. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 13:55 delete

    moneyideas

  3. Subject different money making ideas

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

    moneyideas