Code for recording guest names using javascript
<Script language = "JavaScript"> <! -- Begin 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 ("äúµä× {{{}£°"); SetCookie ('visitorname', VisitorName, exp);} return VisitorName ;} function When (info) {var rightNow = new Date () var WWHTime = 0; WWHTime = GetCookie ('wwhenh') WWHTi Me = WWHTime * 1 var lastHereFormatting = new Date (WWHTime); var intLastVisit = (lastHereFormatting. getYear () * 10000) + (lastHereFormatting. getMonth () * 100) + lastHereFormatting. getDate () var lastHereInDateFormat = "" + lastHereFormatting; var dayOfWeek = lastHereInDateFormat. substring (0, 3) var dateMonth = lastHereInDateFormat. substring (4, 11) var timeOfDay = lastHereInDateFormat. substring (11,16) v Ar year = lastHereInDateFormat. substring (23,25) var WWHText = dayOfWeek + "," + dateMonth + "at" + timeOfDay SetCookie ("WWhenH", rightNow. getTime (), exp) return WWHText} function Count (info) {var WWHCount = GetCookie ('wwhcount') if (WWHCount = null) {WWHCount = 0 ;} else {WWHCount ++;} SetCookie ('wwhcount', WWHCount, exp); return WWHCount;} function set () {VisitorName = prompt ("Who are yo U? "); SetCookie ('visitorname', VisitorName, exp); SetCookie ('wwhcount', 0, exp); SetCookie ('wwhenh', 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 = Lead E Nt. 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 ();} // End --> script
[Ctrl + A Select All Note: If you need to introduce external Js, you need to refresh it to execute]