我在主页中遇到简单的弹出新闻通讯问题...... 基本上在我关闭弹出窗口后,如果刷新主页,弹出窗口会出现大约一秒钟然后消失。
这是代码:
function popup(){
$('.jsclosepoup').on('click', function() {
$('.jsengo_popup').addClass('d-none');
});
}
<section class="popup jsengo_popup">
<div class="modal-window">
<div class="window-window">
<div class="window-content clearfix">
<a class="close_edit jsclosepoup" title="Close" href="javascript:void(0)">ù
Something useful for Newsletter...
</a>
</div>
</div>
</div>
</section>
似乎“d-none”类仅在所有 html 加载后才应用。 如果我已经关闭了新闻通讯,我想阻止它出现一秒钟......
这是我找到的完整代码:
function popup(){
$('.jsclosepoup').on('click', function() {
$('.jsengo_popup').addClass('d-none');
});
}
function cookiepopup(){
if (!jQuery.cookie('brilliant_pop_newletter') || jQuery.cookie('brilliant_pop_newletter') == null) {
jQuery(window).on('load', function() {
setTimeout($('.jsengo_popup').show(), 300 * 1000);
jQuery('.jsclosepoup').click(function(e) {
e.preventDefault();
jQuery('.jsengo_popup').hide();
jQuery.cookie('brilliant_pop_newletter', '1', {expires: 1, path:'/', domain: '{{shop.url}}' });
});
});
} else {
$('.jsengo_popup').remove();
}
}