怎样在网页中读写cookies文件 没错啊,可能跟IE的版本有关http://www.kupage.com/webdesign/6/20040113/1602080000027uu7ws2a.htm 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 // Example:// alert( readCookie("myCookie") );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;}// Example:// writeCookie("myCookie", "my name", 24);// Stores the string "my name" in the cookie "myCookie" which expires after 24 hours.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;} js 改变表格宽度 JS调用问题! javascript构造函数的prototype默认是不是Object.prototype呢?若不是,则构造函数的prototype什么对象呢? 如何将PHP的变量写到状态栏中 难道我发现了微软的一个bug?? 请问怎么编程选中网页中的某一段内容。急切等待中。。。。。。 javascript中字符串怎样比较大小? 请大家推荐一个网页表格的制作工具,(急用) JavaScript迷惑问题之九:如何对URL进行编码? CHECKBOX的问题. 在IE中如何调试框架页面指定某一帧的脚本? 不知道为什么一个js的例子报错,怪事
// alert( readCookie("myCookie") );
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;
}
// Example:
// writeCookie("myCookie", "my name", 24);
// Stores the string "my name" in the cookie "myCookie" which expires after 24 hours.
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;
}