Javascript code _ javascript skills for recording guest names

Source: Internet
Author: User
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]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.