以下の記事は海外の記事です。
http://www.jb51.net/article/20553.htm
var sel = new Object();
var sel_num = 0;
function getCookieVal(offset) {
var endstr = 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;
var clen = document.cookie.length; alert(document.cookie.length);
var i = 0;
while (i < clen) {
var j = i alen;
if (document.cookie.substring(i, j) = = arg)
return getCookieVal(j);
i = document.cookie.indexOf(" ", i) 1;
if (i == 0) Break; 🎜>return null;
}
function SetCookie(名前, 値, 期限切れ, パス, ドメイン, セキュア) {
document.cookie = name "=" エスケープ(値) ((期限切れ) ? ";期限切れ = 期限切れ.toGMTString() : "") ((パス) ? "; パス = パス : "") ((ドメイン) ? "; ドメイン="ドメイン : "") ((安全) ? "; 安全" : " ");
戻り値;
}
関数 DeleteCookie(name) {
if (GetCookie(name) != null) {
SetCookie(name, "", null , "/ ", null);
}
}
function cookie_content() {
i = 0;
for (sel のキー) {
if (i == 0) {
content = key "[" sel[key] "]";
}
else {
content = "," key "[" sel [キー] "]";
}
内容を返す;
関数 inni_data() {
var cookie_sel = new Object(); = GetCookie( "メンバー_COOKIE");
if (cookie_str != "" && cookie_str != null) {
cookie_sel = cookie_str.split(',');
for (var k = 0; k < cookie_sel .length; k ) {
i = cookie_sel[k].indexOf("]"); k].substring(0, i)] = cookie_sel[k].substring(i 1, j);
sel_num ;
}
; >関数 addMember (id, nm) {
if (!sel[id]) {
sel_num ;
}
else
{sel[id] = nm;}
SetCookie("Member_COOKIE", cookie_content(), null, "/", null);
}
functiondraw() {
out =
for ( sel のキー) {
$("#" key).val(sel[key] );
}
}