Este ejemplo de artículo describe el método de grabar nombres de invitados basados en cookies por JS. Compártelo para su referencia, como sigue:
< xmlns = "http://www.w33.org/1999/xhtml"> <Head> <meta http-equiv = "Content-type" content = "text/html; charset = utf-8"/> <title> un documento titulado Date (); exp.setTime (exp.getTime () + (expdays*24*60*60*1000)); Cuando (info) {var rightnow = new Date () var wwhtime = 0; wwhtime = getcookie ('wHhenh') wwhtime = wwhtime * 1var lASTHERAFORMATTING = new Date (wwhtime); var intLastVisit = (lASTHEREFORMATTTING.getYear () * 10000) +(LASTHEREFORTTING lasthereFormatting.getDate () var lasthereIndateFormat = "" + lASTHEREFORTTING; var dayOfWeek = LASTHEREDATEFORMAT.SUBSTRING (0,3) var DataMonth = lasthereIndateFormat.substring (4,11) var tiempo de tiempo = lASTHERINTINGAFORMAT.SUBSTRING (11,16) LasthereIndateFormat.substring (23,25) var wwhtext = dayofweek + "," + datemonth + "at" + timeOfdaySetCookie ("whubehenh", rightnow.getTime (), exp) return wwhtext} function count (info) {var wwhCount = getcookie ('wwhCount') if ((wwhCount) = 0;}else{WWHCount++;}SetCookie ('WWHCount', WWHCount, exp);return WWHCount;}function set(){VisitorName = prompt("Who are you?");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 + "=" = "; 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 (nombre, valor) Setcookie.arguments; var argc = setcookie.arguments.length; var expires = (argc> 2)? argv [2]: null; var ruta = (argc> 3)? argv [3]: null; var dominio = (argc> 4)? argv [4]: null; var secure = (argc> 5)? argv [5]: false; document.cookie = name + "=" + escudo (valor) + ((expires == null)? "": ("; expires =" + expires.togmtString ()) + ((path == null)? "": ";"; path = " + path) + ((domain == null)": ":"; domain = " +" + (domain))) "; Secure": "");} función deletecookie (name) {var exp = new Date (); exp.setTime (exp.getTime () -1); var cval = getcookie (name); document.cookie = name + "=" + cval + "; expires =" + exp.togmtstring ();} // end -> </script <</script <</script <</script </</cval Para esta página, no lo usará en el futuro. Le dirá cuántas veces vienes a esta página cada vez que vengas a esta página, e indicará la hora en que llegó a esta página <br/> <script language = "javascript"> if (count () == 0) {document.write ("¡Hola!" + Quién () + ". Usted está aquí por primera vez, por favor me das más sugerencias valiosas.");} Ose {Document.write ("Hello +". Aquí " + Count () +" Tiempo, la última vez es " + When () +". ");} </script> </body> </html>For more information about JavaScript related content, please check out the topics of this site: "Summary of JSON operation skills in JavaScript", "Summary of JavaScript switching effects and techniques", "Summary of JavaScript search algorithm skills", "Summary of JavaScript animation special effects and techniques", "Summary of JavaScript errors and debugging skills", "Summary of JavaScript data structures and Habilidades de algoritmo "," Resumen de los algoritmos y técnicas de traversal JavaScript "y" Resumen del uso de operaciones matemáticas de JavaScript "
Espero que este artículo sea útil para la programación de JavaScript de todos.