LifeType 中文開發論壇

開發 => 外掛程式 => 主題作者是: Javor 於 六月 26, 2007, 12:28:43 下午



主題: remembercommentdata的一个可能会造成乱码的bug修复
作者: Javor六月 26, 2007, 12:28:43 下午
在remembercommentdata.js里面,对setCookies和readCookies都做编码:
function setCookies() {
    var theForm = document.forms['NewComment'];
    var theName = theForm.userName.value;
    theName = encodeURIComponent(theName);
    createCookie("plog_cm_name", theName, 180);
    createCookie("plog_cm_email", theForm.userEmail.value, 180);
    createCookie("plog_cm_url", theForm.userUrl.value, 180);
    return true;
}

function readCookies() {
    var theForm = document.forms['NewComment'];
    var theName = readCookie("plog_cm_name");
    theName = decodeURIComponent(theName);
    var theAddr = readCookie("plog_cm_email");
    var theUrl = readCookie("plog_cm_url");
    theForm.userName.value = (theName==null)?"":theName;
    theForm.userEmail.value = (theAddr==null)?"":theAddr;
    theForm.userUrl.value = (theUrl==null)?"":theUrl;
}
这样,就不会乱码了。