添加延迟到这个时事通讯弹出代码 - jQuery 模态 Window 弹出代码
Add delay to this newsletter popup code - jQuery Modal Window Popup Code
我的网站是https://urbancitee.com,我用的是Ella主题,Shopify平台。
我正在使用这个主题的内置弹出代码:
<script type="text/javascript">// <![CDATA[
jQuery(document).ready(function() { //
var $modalParent = jQuery('div.newsletterwrapper'),
modalWindow = jQuery('#email-modal'),
emailModal = jQuery('#email-modal'),
modalPageURL = window.location.pathname;
modalWindow = modalWindow.html();
modalWindow = '<div id="email-modal">' + modalWindow + '</div>';
$modalParent.css({'position':'relative'});
jQuery('.wrapper #email-modal').remove();
$modalParent.append(modalWindow);
if (jQuery.cookie('emailSubcribeModal') != 'closed') {
openEmailModalWindow();
};
jQuery('#email-modal .btn.close').click(function(e) {
e.preventDefault();
closeEmailModalWindow();
});
jQuery('body').keydown(function(e) {
if( e.which == 27) {
closeEmailModalWindow();
jQuery('body').unbind('keydown');
}
});
jQuery('#mc_embed_signup form').submit(function() {
if (jQuery('#mc_embed_signup .email').val() != '') {
closeEmailModalWindow();
}
});
function closeEmailModalWindow () {
jQuery('#email-modal .modal-window').fadeOut(600, function() {
jQuery('#email-modal .modal-overlay').fadeOut(600, function() {
jQuery('#email-modal').hide();
jQuery.cookie('emailSubcribeModal', 'closed', {expires:1, path:'/'});
});
})
}
function openEmailModalWindow () {
jQuery('#email-modal').fadeIn(600, function() {
jQuery('#email-modal .modal-window').fadeIn(600);
});
}
});
// ]]
// ]]></script>
请帮我给这个弹出窗口添加延迟 windows,大约 60 秒。非常感谢!!!
您可以使用 setTimeout() 方法:
https://www.w3schools.com/jsref/met_win_settimeout.asp
https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout
您使用 setTimeout 并包括所需的毫秒数延迟。
if (jQuery.cookie('emailSubcribeModal') != 'closed') {
setTimeout(openEmailModalWindow, 60000);
};
我的网站是https://urbancitee.com,我用的是Ella主题,Shopify平台。
我正在使用这个主题的内置弹出代码:
<script type="text/javascript">// <![CDATA[
jQuery(document).ready(function() { //
var $modalParent = jQuery('div.newsletterwrapper'),
modalWindow = jQuery('#email-modal'),
emailModal = jQuery('#email-modal'),
modalPageURL = window.location.pathname;
modalWindow = modalWindow.html();
modalWindow = '<div id="email-modal">' + modalWindow + '</div>';
$modalParent.css({'position':'relative'});
jQuery('.wrapper #email-modal').remove();
$modalParent.append(modalWindow);
if (jQuery.cookie('emailSubcribeModal') != 'closed') {
openEmailModalWindow();
};
jQuery('#email-modal .btn.close').click(function(e) {
e.preventDefault();
closeEmailModalWindow();
});
jQuery('body').keydown(function(e) {
if( e.which == 27) {
closeEmailModalWindow();
jQuery('body').unbind('keydown');
}
});
jQuery('#mc_embed_signup form').submit(function() {
if (jQuery('#mc_embed_signup .email').val() != '') {
closeEmailModalWindow();
}
});
function closeEmailModalWindow () {
jQuery('#email-modal .modal-window').fadeOut(600, function() {
jQuery('#email-modal .modal-overlay').fadeOut(600, function() {
jQuery('#email-modal').hide();
jQuery.cookie('emailSubcribeModal', 'closed', {expires:1, path:'/'});
});
})
}
function openEmailModalWindow () {
jQuery('#email-modal').fadeIn(600, function() {
jQuery('#email-modal .modal-window').fadeIn(600);
});
}
});
// ]]
// ]]></script>
请帮我给这个弹出窗口添加延迟 windows,大约 60 秒。非常感谢!!!
您可以使用 setTimeout() 方法:
https://www.w3schools.com/jsref/met_win_settimeout.asp
https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout
您使用 setTimeout 并包括所需的毫秒数延迟。
if (jQuery.cookie('emailSubcribeModal') != 'closed') {
setTimeout(openEmailModalWindow, 60000);
};