[英]JQuery and cookie Popup Box
我有一个显示表单的弹出窗口。 我只希望它在用户第一次进入网站时显示一次,然后在不再显示时显示一次。 下面的代码不起作用,没有cookie,并且弹出窗口正常。
<script language="javascript" type="text/javascript">
window.onload=function(){
if(jQuery.cookie("popup") != "false"){
jQuery("#subscribePop").bPopup({
modal: true
});
jQuery.cookie("popup","false");
return false
}
}
</script>
我仍然无法使用此代码进行此操作,没有错误或没有任何错误。 还有另一种方法可以做到这一点吗,只是希望div在他们进入时显示一次,然后在该用户关闭后不再显示
这是最好的方法吗? 我愿意接受其他建议:)
<script type="text/javascript">
jQuery(document).ready(function($){
if (!$.cookie("popup")) {
//trigger your popup message
$("#subscribePop").trigger('create'); //or whatever command you have for pop-ing it
//after pop-up show, rewrite the cookie
$.cookie("popup","false"); //not to show again
}
else
{
$("#subscribePop").trigger('destroy'); //or whatever
}
});
</script>
希望它能以某种方式帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.