<Script language = "JavaScript">
<! -- Hide this script from old browsers --
Var expDays = 30;
Var exp = new Date ();
Exp. setTime (exp. getTime () + (expDays * 24*60*60*1000 ));
Function Who (info ){
Var VisitorName = GetCookie ('visitorname ')
If (VisitorName = null ){
VisitorName = prompt ("Enter name :",'');
SetCookie ('visitorname', VisitorName, exp );
}
Return VisitorName;
} Function When (info ){
Var rightNow = new Date ()
Var WWHTime = 0;
WWHTime = GetCookie ('whenh ')
WWHTime = WWHTime * 1
Var lastHereFormatting = new Date (WWHTime); // Date-I-fy that number
Var intLastVisit = (lastHereFormatting. getYear () * 10000) + (lastHereFormatting. getMonth () * 100) + lastHereFormatting. getDate ()
Var lastHereInDateFormat = "" + lastHereFormatting; // Gotta use substring functions
Var dayOfWeek = lastHereInDateFormat. substring (0, 3)
Var dateMonth = lastHereInDateFormat. substring (4, 11)
Var timeOfDay = lastHereInDateFormat. substring (11,16)
Var year = lastHereInDateFormat. substring (23, 25)
Var WWHText = dayOfWeek + "," + dateMonth + "at" + timeOfDay // display
SetCookie ("WWhenH", rightNow. getTime (), exp)
Return WWHText;
}
Function Count (info ){
Var WWHCount = GetCookie ('wwhcount ')
If (WWHCount = null ){
WWHCount = 0;
}
Else {
WWHCount ++;
}
SetCookie ('whcount', WWHCount, exp );
Return WWHCount;
}
Function set (){
VisitorName = prompt ("?????? ",'');
SetCookie ('visitorname', VisitorName, exp );
SetCookie ('whcount', 0, exp );
SetCookie ('whenh', 0, exp );
}
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 ();
Exp. setTime (exp. getTime ()-1 );
// This cookie is history
Var cval = GetCookie (name );
Document. cookie = name + "=" + cval + "; expires =" + exp. toGMTString ();
}
// -- End Hiding Here -->
</Script>
Add the following original code between <body> </body>:
<Script language = "JavaScript">
<! -- Hide this script from old browsers --
Document. write ("Hello <B>" + Who () + "</B>, you are the <B>" + Count () + "</B> visits to the home page. the last time is <B> "+ When () +" </B>. ")
Document. write ('<a href = "JavaScript: set ()"> [Change the name here] </a> ')
// -- End Hiding Here -->
</Script>