【发布时间】:2015-06-17 09:38:39
【问题描述】:
我正在尝试设置一个 cookie 只显示一次弹出窗口,这是我目前的代码:
jQuery(window).load(function(){
// Load pop up within parent-page section only
if (window.location.href.indexOf('parent-page') > -1) {
alert("your url contains the parent-page in the URL");
$.magnificPopup.open({
items: [
{
src: '#disclaimer', // CSS selector of an element on page that should be used as a popup
type: 'inline'
}
],
removalDelay: 300,
mainClass: 'mfp-fade',
closeOnContentClick: false,
modal: true
});
}
});
目前每次父页面在 URL 中时都会加载,我只需要显示一次。我该怎么做?
【问题讨论】:
-
正如您所说,将看到的状态存储在 cookie 或本地存储中!你有沿着这条路的一些代码吗?
-
取决于您希望它不出现在当前会话还是 x 天?
标签: javascript jquery cookies