[Back to
 previous page] [Next Page
 in Series]

Ken Ward's Java Script Tutorial ...

Cookies 6

Telling users how many visits to the page, they have made.

If you entered your name, then you get a welcome above. If you return to this page, it will remember you and greet you with your name.

The code in the BODY above is:

<script type="text/javascript">

<!--//

NewNamer()

VisitCounter()

//-->

</script>

The same as before with the addition of  VisitCounter. to count and display the number of visits to the page. VisitCounter has the following code:

function VisitCounter(){

var visits = GetCookie("counter");

if (!visits) { visits = 1;

document.write("By the way, this is your first time here.");

}

else {

visits = parseInt(visits) + 1;

document.write("I note, you have been here " + visits + " times.");}

setCookie("counter", visits,expdate);

The jsEditor contains a cookie wizard to put the basic code into your page. You can modify this code to create the effects you want. In addition to its many other features, you can use the jsEditor's knowledge base to explore the Math object. You can order the jsEditor online and download the full version immediately, so in a few minutes you could be using it to help you learn and develop scripts.

 

 

Ken Ward's HTML Guide...