这是我的弹出代码。我想在用户进入网站1分钟后显示它。如果用户关闭它将在20分钟内打开,或者在20分钟后重新打开页面刷新。我想用jquery来做。
<div class="subs-popup" style="display:none;">
<div id="consult">
<div class="closepopup">x</div>
<p>Lorem Ipsum is simply dummy text.</p>
</div>
</div>
答案 0 :(得分:0)
首先,创建一个启动模态的函数[TriggerModal(); ]然后使用此代码
<script>
//for open modal after 1sec
setTimeout(function(){
$('.subs-popup').TriggerModal('show');
},1000);
//for close popup
$(".closepopup").click(function(){
//immediately it close modal
$('.subs-popup').hide();
//open modal after 20sec
setTimeout(function(){
$('.subs-popup').TriggerModal('show');
},20000);
});
//if page reloaded
function loaded()
{
$('.subs-popup').removeClass('subs-popup').addClass("newDummy");
setTimeout(function(){
$('.newDummy').addClass('subs-popup');
},19000);
}
window.onload = loaded;
</script>