Ad
Add Delay To This Newsletter Popup Code - JQuery Modal Window Popup Code
My website is https://urbancitee.com , I'm using Ella theme, Shopify platform.
I'm using built-in popup code of this theme:
<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>
Please help me to add a delay to this popup windows, about 60s. Thank you very much!!!
Ad
Answer
You use setTimeout and include desired delay in number of milliseconds.
if (jQuery.cookie('emailSubcribeModal') != 'closed') {
setTimeout(openEmailModalWindow, 60000);
};
Ad
source: stackoverflow.com
Related Questions
- → How to update data attribute on Ajax complete
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → Octobercms Component Unique id (Twig & Javascript)
- → Passing a JS var from AJAX response to Twig
- → Laravel {!! Form::open() !!} doesn't work within AngularJS
- → DropzoneJS & Laravel - Output form validation errors
- → Import statement and Babel
- → Uncaught TypeError: Cannot read property '__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED' of undefined
- → React-router: Passing props to children
- → ListView.DataSource looping data for React Native
- → Can't test submit handler in React component
- → React + Flux - How to avoid global variable
- → Webpack, React & Babel, not rendering DOM
Ad