日期:2014-05-16  浏览次数:20365 次

JS:cookies 存、取、删除实例

?

function SetCookie(name,value)
02 {
03 var Days = 1;
04 var exp = new Date();
05 exp.setTime(exp.getTime() + Days*24*60*60*1000);
06 document.cookie = name + "=" + escape (value) + ";expires=" + exp.toGMTString();
07 }
08 function getCookie(name) //取cookies函数
09 {
10 var arr = document.cookie.match( new RegExp( "(^| )" +name+ "=([^;]*)(;|$)" ));
11 if (arr != null ) return unescape(arr[2]); return null ;
12 ? ?
13 }
14 function delCookie(name) //删除cookie
15 {
16