首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

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

2013-04-05 
js和jQuery 添加、删除、获取cookie? ? ? ? ? ? ? ? ? ?在jquery.cookie.js中 jquery.cookie是一个轻量级的c

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()           }  }     

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

热点排行