发布网友 发布时间:2022-04-21 05:35
共3个回答
热心网友 时间:2023-11-06 05:50
1、获取所有cookie
2、通过名称读取cookie
热心网友 时间:2023-11-06 05:50
用document.cookie, 获取到一个字符串:cookie名1=值1;cookie名=值2alert(document.cookie)试试
热心网友 时间:2023-11-06 05:51
function SetCookie(sName, sValue)
{
document.cookie = sName + "=" + escape(sValue) ;
}function GetCookie(sName)
{
// cookies are separated by semicolons
var aCookie = document.cookie.split("; ");
//alert(document.cookie);
for (var i=0; i < aCookie.length; i++)
{
// a name/value pair (a crumb) is separated by an equal sign
var aCrumb = aCookie[i].split("=");
if (sName == aCrumb[0])
return unescape(aCrumb[1]);
} // a cookie with the requested name does not exist
return "";
}