读书人

js跟jQuery 添加、删除、获取cookie

发布时间: 2013-04-05 10:24:33 作者: rapoo

js和jQuery 添加、删除、获取cookie

? ? ? ?

? ? ? ? ? ?在jquery.cookie.js中 jquery.cookie是一个轻量级的cookie插件,可实现cookie添加、删除、读取。

? ? ? ? ? ? ? ? ? ?首先引用jQuery文件:

? ? ? ? ? ?

?

? ? ? ? ? ? 1、添加cookie

Contains flags for the useragent, read from navigator.userAgent.Available flags are:

safari

opera

msie

mozilla

This property is available before the DOM is ready, therefore you can use it to add ready events only for certain browsers.

There are situations where object detection is not reliable enough, in such cases it makes sense to use browser detection.

?

function clearCookie(){     var keys=document.cookie.match(/[^ =;]+(?=\=)/g);          if (keys) {             for (var i = keys.length; i--;)                 document.cookie=keys[i]+'=0;expires=' + new Date( 0).toUTCString()           }  }     

?? ? ? ? ? ? ? ? ? ? ? ??

读书人网 >JavaScript

热点推荐