web前端|js教程
cookie插件,jquery插件
web前端-js教程
代码:
车手汽修管理软件源码,华为手机刷ubuntu,从哪能弄到爬虫,php 截取后面,seo make uplzw
jQuery.cookie = function(name, value, options) {
if (typeof value != undefined) { // name and value given, set cookie
options = options || {};
if (value === null) {
value = \;
options = $.extend({}, options); // clone object since its unexpected behavior if the expired property were changed
options.expires = -1;
}
var expires = \;
if (options.expires && (typeof options.expires == umber || options.expires.toUTCString)) {
var date;
if (typeof options.expires == umber) {
date = new Date();
date.setTime(date.getTime() (options.expires * 24 * 60 * 60 * 1000));
} else {
date = options.expires;
}
expires = ; expires= date.toUTCString(); // use expires attribute, max-age is not supported by IE
}
// NOTE Needed to parenthesize options.path and options.domain
// in the following expressions, otherwise they evaluate to undefined
// in the packed version for some reason...
var path = options.path ? ; path= (options.path) : \;
var domain = options.domain ? ; domain= (options.domain) : \;
var secure = options.secure ? ; secure : \;
document.cookie = [name, =, encodeURIComponent(value), expires, path, domain, secure].join(\);
} else { // only name given, get cookie
var cookieValue = null;
if (document.cookie && document.cookie != \) {
var cookies = document.cookie.split(;);
for (var i = 0; i < cookies.length; i ) {
var cookie = jQuery.trim(cookies[i]);
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length 1) == (name =)) {
cookieValue = decodeURIComponent(cookie.substring(name.length 1));
break;
}
}
}
return cookieValue;
}
};
使用方法
jQuery操作cookie的插件,大概的使用方法如下
$.cookie(‘the_cookie’); //读取Cookie值
$.cookie(‘the_cookie’, ‘the_value’); //设置cookie的值
$.cookie(‘the_cookie’, ‘the_value’, {expires: 7, path: ‘/’, domain: ‘’, secure: true});//新建一个cookie 包括有效期 路径 域名等
$.cookie(‘the_cookie’, ‘the_value’); //新建cookie
$.cookie(‘the_cookie’, null); //删除一个cookie
设置一个名称为blog,值为的cookie:
$.cookie(“blog”, “”);
设置一个名称为blog,值为的cookie,同时设置过期时间(expires属性)为7天:
$.cookie(“blog”, “”, { expires: 7 });
设置一个名称为blog,值为的cookie,设置过期时间(expires属性)为7天,同时设置cookie的path属性为”/admin”
$.cookie(“blog”, “”, { path: ‘/admin’, expires: 7 });
读取Cookie:
读取名称为blog的cookie值:
alert( $.cookie(“blog”) );
删除cookie:
$.cookie(“example”, null);
手机攻击器易语言源码,vscode zip下载,ubuntu有线网络不识别,tomcat超时处理,qt与sqlite操作,jquery省份选择器插件,前端三大框架 ang,爬虫登录验证码,yum php fpm,溧阳优化seo,仿果壳网站,html网页插件代码,html网站中文模板下载,淘宝客程序 采集lzw