<div class="htmlarea"> <textarea id="runcode8341"> <input type="button" onclick="setCookie()" value="设置a=abcd;b=5678"> <input type="button" onclick="setcookie('a','qq')" value="设置a=qq"> <input type="button" onclick="readcookie('a');" value="读取a"> <input type="button" onclick="readcookie('b');" value="读取b"> </textarea> <br><input onclick="runEx('runcode8341')" type="button" value="运行代码"><input onclick="doCopy('runcode8341')" type="button" value="复制代码"> <input onclick="doSave(runcode8341)" type="button" value="保存代码"> <a href="http://www.jb51.net/article/23421.htm" title="查看具体详情" target="_blank">[Ctrl A 모두 선택 참고: </a>외부 J를 도입해야 하는 경우 실행하려면 새로 고쳐야 합니다 </div>]<script language="javascript"> function setcookie(name, value) { //设置名称为name,值为value的cookie document.cookie = name + "=" + value document.location.reload(); } function setCookie() { document.cookie="a=abcd;" document.cookie="b=5678;" document.location.reload(); } var mycookie = document.cookie; function readcookie(name) { var start1 = mycookie.indexOf(name + "="); if (start1== -1) alert("cookies not found"); else { start=mycookie.indexOf("=",start1)+1; var end = mycookie.indexOf(";",start); if (end==-1) { end=mycookie.length;} var value=unescape(mycookie.substring(start,end)); if (value==null) {alert("No cookies found!");} else {alert("cookie变量:"+name+" 的值是 :"+value);} } } </script>