当我尝试阅读我的饼干,我设置的东西看起来不正确javaScript时髦的cookie?
这里是我的cookie功能
function readCookie(){
if (document.cookie !=""){
document.getElementsByName("eMail").innerHTML = alert("hello, " +
document.cookie.split("=")[1]);
}
}
//for setting cookies
function writeCookie(cName, cValue, expDate, cPath, cDomain, cSecure){
if(cName && cValue!= ""){
var cString = cName + " = " + escape(cValue);
if (expDate) cString += ";expires=" + expDate,toGMString();
if (cPath) cString += ";path=" + cPath;
if (cDomain) cString += ";domain=" + cDomain;
if (cSecure) cString += ";secure";
document.cookie = cString;
}
}
的cookie被设置
<input type="submit" value="Submit"
onclick="writeCookie('userId',document.getElementsByName('eMail').value)"/>
警告框
hello, undefined;__utma
想到这是什么意思?
document.getElementsByName是我将它切换到ID的罪魁祸首,虽然它仍然给我在__UTMA警报字符串结尾 – Overcranked 2011-12-22 03:00:28
@Overcranked - 我真的不知道。我会收集所有更新后的代码,并发布带有错误消息的新问题。 – 2011-12-22 03:13:28