请大家帮忙。js中如何读取cookie阿 是呀,我同意 回复人: GageCSDN(稻草人 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 document.cookie是一个可读写的属性,它是一个String类型的,你可以使用substring(),indexOf(),split()等方法来进行操作它. function readCookie(name)//读{ var cookieValue = ""; var search = name + "="; if(document.cookie.length > 0) { offset = document.cookie.indexOf(search); if (offset != -1) { offset += search.length; end = document.cookie.indexOf(";", offset); if (end == -1) end = document.cookie.length; cookieValue = unescape(document.cookie.substring(offset, end)) } } return cookieValue;}function writeCookie(name, value, hours)//写{ var expire = ""; if(hours != null) { expire = new Date((new Date()).getTime() + hours * 3600000); expire = "; expires=" + expire.toGMTString(); } document.cookie = name + "=" + escape(value) + expire;} JQuery指定位置添加<td> 但是没有添加到想到的位置后面 用javascript怎样实现DW属性面板中的链接作用 使用localStorage为什么无法保存数据? fet mput报错:Couldn't get handle: Permission denied 网页对话框 jquery搜索问题 不信这么小的问题就没有人知道 关于创建快捷方式的问题 谁有在客户端把页面另存为word(excel)的java脚本,最好是butten触发 请高手来更改 新手求教 怎么访问到一个方法里面的变量 把程序嵌入网页的问题,请大家帮忙看看,多谢! 求一个日期格式函数?
{
var cookieValue = "";
var search = name + "=";
if(document.cookie.length > 0)
{
offset = document.cookie.indexOf(search);
if (offset != -1)
{
offset += search.length;
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
cookieValue = unescape(document.cookie.substring(offset, end))
}
}
return cookieValue;
}function writeCookie(name, value, hours)//写
{
var expire = "";
if(hours != null)
{
expire = new Date((new Date()).getTime() + hours * 3600000);
expire = "; expires=" + expire.toGMTString();
}
document.cookie = name + "=" + escape(value) + expire;
}