我试图让我的弹出窗口每次访问或每个用户出现一次。这是一个弹出窗口,要求您订阅。我希望订阅的用户不会收到他们访问网站的弹出加班时间,也不希望多次访问网站(或特别是主页)的用户也不会收到弹出窗口。我曾尝试使用cookie插件,但它无法正常工作。我提供了我一直在玩的弹出式HTML和jQuery。
HTML:
<br>
{% form 'create_customer' %}
<center>
<div id="emailf" class="clearfix large_form">
<label for="email" class="label"></label>
<input type="email" value="" name="customer[email]"placeholder="Email" id="email" class="text" style="text-align:center; margin: 0 auto; width:300px; height:30px;" />
</div>
<div id="password1" class="clearfix large_form">
<label for="password" class="label"></label>
<input type="password" value="" name="customer[password]"placeholder="Password" id="password" class="password text" style="text-align:center; margin: 0 auto; width:300px; height:30px;" />
</div>
<div id="btn1" class="clearfix large_form">
<label for="Create" class="btn1"></label>
<input type="submit" value="SIGN UP!" style="text-align:center; font-weight:bold;margin: 0 auto; width:310px; height:40px;background-color:#852B8A;color:white;" />
</div>
<div id="close">X</div>
<!-- <input class="btn1" type="submit" value="Create" />-->
<!-- <button id="shop"><a href="https://www.alzerina.com/collections/ready-to-wear">Sign Up Now!</a></button> -->
</center>
</div> {% endform %}
jQuery的:
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.js"></script>
<script>
$(document).ready(function(){
if (!$.cookie('alert')) {
$('#popup_box').show();
var date = new Date();
date.setTime(date.getTime() + 24 * 60 * 60 * 1000);
$.cookie('alert', true, { expires: date });
}
});
</script>