Este exemplo de artigo descreve o método de gravar nomes de convidados com base em cookies por JS. Compartilhe -o para sua referência, como segue:
<! xmlns = "http://www.w3.org/1999/xhtml"> <head> <meta http-equiv = "content-type" content = "text/html; charset = utf-8"/> <title> unt titisned </title <spripting <sprinting = " Date (); exp.setTime (exp.gettime () + (expdrays*24*60*60*1000)); função quem (info) {var visitorName = getCookie ('visitorname') se (visitorname == null) {visitorname = prompt ("seu nome homenageado:"); setcookie ('visitornMe) {visitorName = ("seu nome de homenagem:"); setcookie ('; rightNow = new Date()var WWHTime = 0;WWHTime = GetCookie('WWhenH')WWHTime = WWHTime * 1var lastHereFormatting = new Date(WWHTime);var intLastVisit = (lastHereFormatting.getYear() * 10000)+(lastHereFormatting.getMonth() * 100) + lastHereFormatting.getDate()var lastherendateFormat = "" + lasthereformatting; var DayofWeek = lastherendateFormat.substring (0,3) var datemonth = lastherendateFormat.substring (4,11) var timeofday = lastherendEformet.Substring (11,16) = DayofWeek + "," + DATEMONTH + "AT" + timeofDaySetCookie ("wwhenh", rightnow.gettime (), exp) retorna wwhtext} contagem de funções (info) {var wwhcount = getCookie ('wwhcount') se (wwhcount ==l) (wwhcout; ('Wwhcount', wwhcount, exp); retorna wwhcount;} function set () {visitorname = prompt ("quem é você?"); Setcookie ('visitorname', visitorname, exp); setcookie ('wwhcount', 0, exp); setcookie ('wwwhenh', 0, exp); document.cookie.indexOf (";", deslocamento); if (endstr == -1) endstr = document.cookie.length; retorna unescape (document.cookie.substring (deslocamento, endstr);} função getcookie (name) {var = name + "="; {var j = i + Alen; if (document.cookie.substring (i, j) == arg) retorna getCookieval (j); i = document.cookie.indexOf ("", i) + 1; if (i == 0) quebra;} retornar null; SetCookie.argudents.length; var expira = (argc> 2)? argv [2]: nulo; var path = (argc> 3)? argv [3]: null; var domain = (argc> 4)? argv [4]: null; var seguro = (argc> 5)? argv [5]: false; document.cookie = nome + "=" + escape (value) + ((expire == null)? "": ("; expira =" + expira.togmtString ()) + ((path == null)? ": ("; "; true)? Venha para esta página, você não a usará no futuro. Ele lhe dirá quantas vezes você chega a esta página toda vez que chegar a esta página e indica o tempo que chegou pela última vez a esta página <br/> <script linguage = "javascript"> if (count () == 0) {document.write ("hello!" + Quem () + ". Você está aqui pela primeira vez, por favor, dê -me mais sugestões valiosas (); Aqui " + count () +" tempo, a última vez é " + quando () +". ");} </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 "," Resumo dos algoritmos e técnicas de travessia de JavaScript "e" Resumo do uso de operações matemáticas de JavaScript "
Espero que este artigo seja útil para a programação JavaScript de todos.