什么意思.length在document.cookie中 [英] what mean .length in document.cookie
本文介绍了什么意思.length在document.cookie中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以问在javascript中的什么意思document.cookie.length? document.cookie对象中的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 getCookie(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
只是一个字符串,因此 .length
是该字符串的长度。 JavaScript不提供任何内置函数来解析各个Cookie,你必须自己这样做。
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.
这篇关于什么意思.length在document.cookie中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文