如何清除指定网址的cookie值,急等。先谢过大家了。
解决方案 »
- javascript如何取textarea里的每个值;当作数组或者for出来
- canvas内为什么strokeStyle = "rgb(x,x,x)"总为黑色
- 怎么加参数,类似于这样window.opener.location.href=window.opener.location.href?id=...
- 请问这样定义是什么意思啊:~function(){}();
- 哪位达人有什么好的算法快速查找一个数组中模糊匹配某词的所有项?
- 如何让iframe的大小和它所装载的页面里一个表的大小完全一致?
- 用JAVASCRIPT的正则表达式判断字符是否全是字母,MATCH()里面参数怎么写?
- 如何得到一个textbox右上角的相对坐标或是绝对坐标?
- 如何用一个button 获取一个input输入项的值并把值作为超链接打开
- 双逻辑非操作符问题
- IETester 中IE7,IE8 对alert()方法失效了??? ******
- 求两个正则表达式
{
var exp = new Date();
exp.setTime(exp.getTime() - 1);
var cval=getCookie(name);
if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString();
} delCookie('要删除的cookie 名字');
{
var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
if(arr != null) return unescape(arr[2]); return null; } 你还得加个getCookie方法 就这个
document.cookie="key=value";
key,value都需要提前使用encodeURIComponent编码
浏览器关闭的时候,cookie就没有了。
不用设置domain,默认就是赋值cookie的域。
var date = new Date();
date.setTime(date.getTime() - 10000);
document.cookie = name + "=a; expires=" + date.toGMTString();
}