如题,只要 是 保存的 cookie ,全部 读取出来 ?
解决方案 »
- 看了一个例子不懂,问一下, <object id="items" class="System.Collections.ArrayList" runat="server" />
- 弹出遮罩层示例.
- GridView 删除行问题....
- access中求最大值,在线等,急!!!
- 一个判断问题。不知怎样解决?
- 关于孟子E章的多列的DropDownList的实现问个问题!望高手帮忙·!在线等候。
- 用extjs的jsonStore时碰到的问题,求解答
- 我的ASP.NET,IIS,SQL SERVER2000做的系统如何在网上发布??
- web报错
- iis7.5 发布网站 连接数据库出错 在线等解决
- 查询问题,急求助
- 这段图片滚动JS代码怎么解释?
var aCookie = document.cookie.split("; ");
for (var i = 0; i < aCookie.length; i++) {
var aCrumb = aCookie[i].split("=");
if (VName == aCrumb[0])
return unescape(aCrumb[1]);
}
return null;
}
{
var aCookie = document.cookie.split( "; ");
for (var i=0; i < aCookie.length; i++)
{
var aCrumb = aCookie[i].split( "= ");
alert(aCrumb[0] + " = " + aCrumb[1]);
}
}
function SetCookie(key, value)
{
var time = 5*60*1000; // 5分钟(毫秒单位)
var exp = new Date();
exp.setTime(exp.getTime() + time);
document.cookie = key + "=" + escape(value) + ";page=/;expires=" + exp.toGMTString();
}// 取cookies
function getCookie(key)
{
var arr = document.cookie.match(new RegExp("(^| )" + key+ "=([^;]*)(;|$)"));
if (arr != null) return unescape(arr[2]);
return null;}// 删除cookie
function delCookie(key)
{
var exp = new Date();
exp.setTime(exp.getTime() - 1);
var cval = getCookie(key);
if (cval != null) document.cookie = key+ "=" + cval + ";expires=" + exp.toGMTString();
}有两点特别要注意:
1. 使用一个键存储值到cookie,有大小限制的,最多不超过4kb,如果你存储的值可能超过(例如,分页批量选择,存储选中项的id)4kb,则做一个特殊处理,分多个键存储。
2. SetCookie()中注意一项参数“path=/”,如果不设置这个参数,在频繁操作分页数据时,会遇到cookie莫名丢失,或者清除不掉的bug,设置path,才能避免这个问题。