设置cookie 函数直接上代码:
function setCookie(name, value, days) { //设置cookie var d = new Date(); d.setTime(d.getTime() + (days * 24 * 60 * 60 * 1000)); var expires = "expires=" + d.toUTCString(); document.cookie = name + "=" + value + "; " + expires; }
设置cookie:
setCookie("key", 'value', 1);
cookie检测:
document.cookie.indexOf("key")
返回值 -1表示不存在此cookie
本文章地址http://www.vzeo.com/news/xuetang/800696.html 由 友站网 编辑整理,转载请注明出处