クッキー操作
コード
(function(d){ var E=d.createElement, T=d.createTextNode, A=function(r,e){r.appendChild(e)}, r=E('div'),e,t; with(r.style){ position='fixed'; top='5px'; left='5px'; zIndex=10000; width='410px'; height='250px'; border='1px solid black'; backgroundColor='white' } A(r,T('クッキー')); A(r,e=E('a')); A(e,T('×')); e.onclick=function(d,e){return function(){ d.body.removeChild(e) }}(d,r); A(r,E('br')); A(r,e=E('textarea')); e.value=d.cookie; with(e.style){ width='400px'; height='200px' } A(r,t=E('button')); A(t,T('セット')); t.onclick=function(d,e){return function(){ d.cookie=e.value }}(d,e); A(d.body,r) })(document)
解説
基本的に「リンク一覧」や「画像一覧」と変わりありません。ただ注意したいのは、
「セット」ボタンを押しても「document.cookie=(textareaの中身)」とされるだけなので、
textareaの中身がそのままcookieになるわけではないことです。
余談
いまどきクッキーなんて流行らないと思うのです。
アクセス回数16790億回(365×46億)とかやってしまいましょう。
1行スクリプト ホーム