Javascript 使用JS Cookie向Modal添加Cookie 我用基金会和JS Cookie构建了一个时事通讯模式。我已经让模态正常工作了,只需要把曲奇弄对就行了

Javascript 使用JS Cookie向Modal添加Cookie 我用基金会和JS Cookie构建了一个时事通讯模式。我已经让模态正常工作了,只需要把曲奇弄对就行了,javascript,cookies,zurb-foundation,Javascript,Cookies,Zurb Foundation,这是我的JS $(文档).ready(函数(){ if(Cookies.get('show_newsletter','false')){ setTimeout(函数(){ $('myModal2')。基金会('open'); set('show_newsletter','true',{expires:7}); },3000)//3秒。 } }); .embed container{位置:相对;填充底部:56.25%;高度:0;溢出:隐藏;最大宽度:100%;}.embed container

这是我的JS

$(文档).ready(函数(){
if(Cookies.get('show_newsletter','false')){
setTimeout(函数(){
$('myModal2')。基金会('open');
set('show_newsletter','true',{expires:7});
},3000)//3秒。
}
});

.embed container{位置:相对;填充底部:56.25%;高度:0;溢出:隐藏;最大宽度:100%;}.embed container iframe、.embed container对象、.embed container embed{位置:绝对;顶部:0;左侧:0;宽度:100%;高度:100%;}
&时代;
表示
.get()
方法只接受一个[可选]参数:cookie名称

因此,请测试您的cookie是否像这样存在

if (!Cookies.get('showed_newsletter'))
如果没有,将返回一个
未定义的

Cookies.get('nothing');//=>未定义

$(文档).ready(函数(){
如果(!Cookies.get('show_newsletter')){
setTimeout(函数(){
$('myModal2')。基金会('open');
set('show_newsletter','true',{expires:7});
},3000)//3秒。
}
});

.embed container{位置:相对;填充底部:56.25%;高度:0;溢出:隐藏;最大宽度:100%;}.embed container iframe、.embed container对象、.embed container embed{位置:绝对;顶部:0;左侧:0;宽度:100%;高度:100%;}
&时代;