この記事の例では、JSのCookieに基づいてゲスト名を記録する方法について説明します。次のように、参照のために共有してください。
<!doctype html public " - // w3c // dtd xhtml 1.0 transitional // en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns = "http://www.w3.org/1999/xhtml"> <head> <meta http-equiv = "content-type" content = "text/html; charset = utf-8"/> <title> untled document </title = <"> < date(); exp.settime(exp.gettime() +(expdays*24*60*60*1000)); function who(info){var visitorname = getcookie( 'visitorname')if(visitorname == null){visitorname = prompt( "your honored name:"); setorname( 'visitorname'、visitorname、} rightnow = new date()var wwhime = 0; wwhtime = getcookie( 'whenh')wwhime = wwhime * 1var lastereformatting = new date(wwhime); var intlastvisit =(lasthereformatting.getyear() * 10000) +(lashereformatting.getmonth() lasthereindateformat = "" + lasthereformatting; var dayofweek = lasthereindateformat.substring(0,3)var datemonth = lashereindateformat.substring(4,11)var time = lashereindateformat.substring(11,16)var = lasreindateformat. = dayofweek + "、" + datemonth + "at" + timeofdaysetcookie( "whenh"、rightnow.gettime()、return wwhtext} function count} function count {var wwhcount = getcookie( 'wwhcount')if(wwhcount == null){wwhcount = 0;} ( 'wwhcount'、wwhcount、exp); return wwhcount;} function set(){visitorname = prompt( "who are you?"); setcookie( 'visitorname'、visitorname、exp); setcookie( 'wwhcount'、0、exp); setcookie( 'wwhenh'、edscookie( 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; clen){var j = i + alen; if(document.cookie.substring(i、j)== return getcookieval(j); i = document.cookie.indexof( ""、i) + 1; if(i == 0)break;} return null;} function setcookie(name){var argv = setcookie.Arguments; 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) "; secure": "");} function deletecookie(name){var exp = new date(); exp.settime(exp.gettime() - 1); var cval = getcookie(name); document.cookie = name + "=" + cval + "; expires ="ページ、将来は使用しません。このページに来るたびにこのページに何回来るかを教えてくれ、最後にこのページに来た時期を示します<br/> <スクリプト言語= "javascript"> if(count()== 0){document.write( "hello!" + " +"。あなたは初めてここにいます。 here " + count() +" time、最後は " + when() +"。 ");} </script> </body> </html>JavaScript関連のコンテンツの詳細については、このサイトのトピックをご覧ください:「JavaScriptのJSONオペレーションスキルの要約」、「JavaScriptの切り替え効果とテクニックの概要」、「JavaScript Search Algorithm Skills」、「Javascript Animation Animation Special Effects and Techniquesの要約」、Javascriptの概要「Debugn of of debugging of Javing」アルゴリズムスキル」、「JavaScriptトラバーサルアルゴリズムとテクニックの要約」および「JavaScriptの数学操作の使用法の要約」
この記事がみんなのJavaScriptプログラミングに役立つことを願っています。