firefox里面使用cookie的问题
Dear All:
在IE里面运行正常的javascript程序,在firefox里面有问题,不知道大家有没有遇到过类似的问题.
调用delCookie无效.
function setCookie(name, value)
//设定Cookie值
{
var expdate = new Date();
var argv = setCookie.arguments;
var argc = setCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
if(expires!=null) expdate.setTime(expdate.getTime() + ( expires * 1000 ));
document.cookie = name + "= " + escape (value) +((expires == null) ? " " : ( "; expires= "+ expdate.toGMTString()))
+((path == null) ? " " : ( "; path= " + path)) +((domain == null) ? " " : ( "; domain= " + domain))
+((secure == true) ? "; secure " : " ");
}
function delCookie(name)
//删除Cookie
{
var exp = new Date();
exp.setTime (exp.getTime() - 1);
var cval = getCookie (name);
document.cookie = name + "= " + cval + "; expires= "+ exp.toGMTString();
}
function getCookie(name)
//获得Cookie的原始值
{
var arg = name + "= ";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen)
{
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = document.cookie.indexOf( " ", i) + 1;
if (i == 0) break;
}
return " ";
}
function getCookieVal(offset)
//获得Cookie解码后的值
{
var endstr = document.cookie.indexOf ( "; ", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
------解决方案--------------------JF
------解决方案--------------------我也遇到这个问题。。。。。。。。。