pokemon
October 12th, 2006, 07:32 AM
this script will aks the visitor of your site for its name and the name will be saved.Now whenever that visitor visits your site again your site will display
that how many times the visitor has visited your site.
<script>
var UserName = GetWBCookie('UserName'); var UserVisits = GetWBCookie('UserVisits'); function WBWho(info){ if (UserName == null) { UserName = prompt('Please Enter Your First Name',''); if ((UserName == '') || (UserName == null)) UserName = ''; var FirstLetter = UserName.substring(0, 1).toUpperCase(); var RestOfWord = UserName.substring(1, UserName.length).toLowerCase(); UserName = FirstLetter+RestOfWord; SetWBCookie('UserName', UserName); } return UserName;} function WBCount(info){ if (UserVisits == null) UserVisits = 0; else UserVisits++; SetWBCookie('UserVisits', UserVisits); if (UserVisits == 0) return 'Welcome To Our WebSite!'; if (UserVisits == 1) return 'you have been here 1 time before.'; return 'you have been here ' + UserVisits + ' times before.';} function WBWhen(info){ var Days = new Array('Sunday','Monday','Tuesday','Wednesday','Thu rsday','Friday','Saturday'); var today = new Date(); var Year = CorrectYear(today); var Month = AddZero(today.getMonth()+1); var DayName = Days[today.getDay()]; var Day = AddZero(today.getDate()); var Hours = today.getHours(); var ampm = 'A.M.'; if (Hours == 0) Hours = 12; if (Hours > 11) ampm = 'P.M.'; if (Hours > 12) Hours -= 12; Hours = AddZero(Hours); var Minutes = AddZero(today.getMinutes()); var Seconds = AddZero(today.getSeconds()); WBWhenText= DayName + ' ' + Month + '-' + Day + '-' + Year+' '+Hours + ':' + Minutes + ':' + Seconds + ' ' + ampm; SetWBCookie ('UserLastHere',WBWhenText); if (UserVisits == 0) return ''; return 'Last visit was on ' +WBWhenText;} function AddZero(num){ if (num < 10) num = '0' + num; return num;} function CorrectYear(theDate){ x = theDate.getYear(); var y = x % 100; y += (y < 38) ? 2000 : 1900; return y;} function GetWBCookie(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 GetWBCookieVal (j); i = document.cookie.indexOf(' ', i) + 1; if (i == 0) break; } return null;} function SetWBCookie (name, value){ document.cookie = name + '=' + escape (value);} function GetWBCookieVal (offset){ var endstr = document.cookie.indexOf (';', offset); if (endstr == -1) endstr = document.cookie.length; return unescape(document.cookie.substring(offset, endstr));}
document.write('<font style=" font-family: ; color: #000000; font-size: 10pt; text-decoration: none; font-weight: normal; font-style: normal;">Hello ' + WBWho() + ', ' + WBCount() + ' ' + WBWhen() + '<font>');
</script>
that how many times the visitor has visited your site.
<script>
var UserName = GetWBCookie('UserName'); var UserVisits = GetWBCookie('UserVisits'); function WBWho(info){ if (UserName == null) { UserName = prompt('Please Enter Your First Name',''); if ((UserName == '') || (UserName == null)) UserName = ''; var FirstLetter = UserName.substring(0, 1).toUpperCase(); var RestOfWord = UserName.substring(1, UserName.length).toLowerCase(); UserName = FirstLetter+RestOfWord; SetWBCookie('UserName', UserName); } return UserName;} function WBCount(info){ if (UserVisits == null) UserVisits = 0; else UserVisits++; SetWBCookie('UserVisits', UserVisits); if (UserVisits == 0) return 'Welcome To Our WebSite!'; if (UserVisits == 1) return 'you have been here 1 time before.'; return 'you have been here ' + UserVisits + ' times before.';} function WBWhen(info){ var Days = new Array('Sunday','Monday','Tuesday','Wednesday','Thu rsday','Friday','Saturday'); var today = new Date(); var Year = CorrectYear(today); var Month = AddZero(today.getMonth()+1); var DayName = Days[today.getDay()]; var Day = AddZero(today.getDate()); var Hours = today.getHours(); var ampm = 'A.M.'; if (Hours == 0) Hours = 12; if (Hours > 11) ampm = 'P.M.'; if (Hours > 12) Hours -= 12; Hours = AddZero(Hours); var Minutes = AddZero(today.getMinutes()); var Seconds = AddZero(today.getSeconds()); WBWhenText= DayName + ' ' + Month + '-' + Day + '-' + Year+' '+Hours + ':' + Minutes + ':' + Seconds + ' ' + ampm; SetWBCookie ('UserLastHere',WBWhenText); if (UserVisits == 0) return ''; return 'Last visit was on ' +WBWhenText;} function AddZero(num){ if (num < 10) num = '0' + num; return num;} function CorrectYear(theDate){ x = theDate.getYear(); var y = x % 100; y += (y < 38) ? 2000 : 1900; return y;} function GetWBCookie(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 GetWBCookieVal (j); i = document.cookie.indexOf(' ', i) + 1; if (i == 0) break; } return null;} function SetWBCookie (name, value){ document.cookie = name + '=' + escape (value);} function GetWBCookieVal (offset){ var endstr = document.cookie.indexOf (';', offset); if (endstr == -1) endstr = document.cookie.length; return unescape(document.cookie.substring(offset, endstr));}
document.write('<font style=" font-family: ; color: #000000; font-size: 10pt; text-decoration: none; font-weight: normal; font-style: normal;">Hello ' + WBWho() + ', ' + WBCount() + ' ' + WBWhen() + '<font>');
</script>