【发布时间】:2014-04-30 17:24:32
【问题描述】:
我们用fancybox构建了一个通知,需要向所有用户显示一次,但目前它在网站的每个页面上显示一次,并为访问者访问的每个页面设置一个cookie,我们的代码如下:
// jQuery Cookie popup
$(function() {
if ($.cookie('cd-notification-cookie')) {
// it hasn't been three days yet
} else {
$.fancybox.open([
{
href : '#notification'
}
], {
maxWidth : 420,
maxHeight : 800,
fitToView : false,
width : '90%',
height : 'auto',
autoSize : false,
closeClick : false,
closeEffect : 'none'
});
// set cookie to expire in 3 days
$.cookie('cd-notification-cookie', 'true', { expires: 3});
}
});
是否可以为整个网站而不是每页设置一个全局 cookie?
【问题讨论】:
标签: jquery cookies jquery-cookie