|
|
|
|
<HTML><HEAD> <meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS"> <TITLE>訪問者名記憶のソース</TITLE> <SCRIPT LANGUAGE="JavaScript"> // cookieを切り分ける function getCookie(name){ // cookie名は必ず@マークで始まる var cName = name + "="; var cNameLen = cName.length var myCookie = document.cookie; var startPos = myCookie.indexOf(cName); var endPos; if (document.cookie.length == 0 ) return null; if (startPos != -1) { startPos = startPos + cNameLen; endPos = myCookie.indexOf(";", startPos); //「;」がなければ最後の要素 if (endPos == -1) endPos = document.cookie.length; return unescape(myCookie.substring(startPos,endPos)); } return null; } // cookieをセットする function setCookie(name,value,expire) {; document.cookie= name + "=" + escape(value) + "; expires=" + expire.toGMTString(); } </SCRIPT> </HEAD> <BODY> <center> <strong> <font size=+3 color=#ff0000>訪問者名記憶</font> <hr> <SCRIPT LANGUAGE="JavaScript"> var expire = new Date(); // 60日後にクッキーを消去 expire.setTime(expire.getTime() + (60*24*60*60*1000)); var numVisits;//訪問回数 var yourName; //訪問者の名前 // 名前が登録されているかどうかの確認 yourName = getCookie("@name"); if (yourName == null){ yourName = prompt("名前をおしえてください",""); if ( (yourName == null) || (yourName == "" ) ){ yourName = "お客"; } setCookie("@name", yourName, expire); } numVisits = getCookie("@num_visits"); if ( numVisits == null ){ numVisits = 0; } numVisits++; setCookie("@num_visits", numVisits, expire); document.write("<CENTER><FONT COLOR=#C71585 SIZE=6>"); document.write("こんにちは",yourName.fontsize(6),"さん"); document.write("<BR>", "今回で"); document.write(numVisits); document.write("回目の訪問ですね。", "<BR>"); document.write("</CENTER></FONT>"); </SCRIPT> </strong> </FONT> </center> </BODY> </HTML>
<HEAD>から</HEAD>の青文字のタグと、<BODY>から</BODY>の青文字のタグをコピーしてみて下さい。
HTMLで開くと初回のみダイアログが現れます。ご自身のHNなどを入力すると、
ご自身の訪問回数が表示されるようになります。
[★高収入が可能!WEBデザインのプロになってみない?!
自宅で仕事がしたい人必見!
]
[ CGIレンタルサービス | 100MBの無料HPスペース | 検索エンジン登録代行サービス ]
[ 初心者でも安心なレンタルサーバー。50MBで250円から。CGI・SSI・PHPが使えます。 ]
FC2 | キャッシング 花 | 出会い 無料アクセス解析 | |