what mean .length in document.cookie
Can I ask what mean document.cookie.length in javascript? the number of cookies in document.cookie object Thanks! This is the code:
function ge开发者_运维问答tCookie(c_name)
{
if (document.cookie.length>0)
{
c_start=document.cookie.indexOf(c_name + "=");
if (c_start!=-1)
{
c_start=c_start + c_name.length+1;
c_end=document.cookie.indexOf(";",c_start);
if (c_end==-1) c_end=document.cookie.length;
return unescape(document.cookie.substring(c_start,c_end));
}
}
return "";
}
document.cookie
is simply a string, so .length
is the length of that string. JavaScript doesn't provide any built-in functions to parse the individual cookies, you have to do that yourself.
精彩评论