日期:2014-05-19  浏览次数:20762 次

js删除cookie问题
function reme(obj){
if(obj.checked ==false){
alert("删除cookie ");
var date = new Date();
date.setTime(date.getTime() - 10000);
document.cookie = "userName=a; expires=" + date.toGMTString();
document.cookie = "password=a; expires=" + date.toGMTString();
document.cookie = "rem=a; expires=" + date.toGMTString();
alert("删除完毕 ");
}
  }

<input type="checkbox" onclick="reme(this)">删除cookie

此方法cookie没有被删除,键为“userName”和“password”的还是有值。请问为什么或者有其他好方法,谢谢!

------解决方案--------------------
http://blog.csdn.net/zxmcl/article/details/1723595
------解决方案--------------------
探讨
http://blog.csdn.net/zxmcl/article/details/1723595

------解决方案--------------------
JScript code

    remove: function(key) {
        var value = "";
        document.cookie = key + "=" + escape(value) + "; expires=Fri, 31 Dec 1999 23:59:59 GMT;";
    }