如何:延迟订阅弹出窗口-jQuery

时间:2020-07-14 08:13:44

标签: javascript jquery

我是这个新手。我一直在尝试延迟wordpress中的订阅弹出窗口。它是主题弹出的。我想延迟30秒。

有人可以帮忙吗?

(function ($) {
    "use strict";
    
    var subscribePopup = {};
    eltdf.modules.subscribePopup = subscribePopup;
    
    subscribePopup.eltdfOnWindowLoad = eltdfOnWindowLoad;
    
    $(window).load(eltdfOnWindowLoad);
    
    /*
     All functions to be called on $(window).load() should be in this function
     */

    function eltdfOnWindowLoad() {
        eltdfSubscribePopup();
    }
                   
    function eltdfSubscribePopup() {
        var popupOpener = $('.eltdf-subscribe-popup-holder'),
            popupClose = $('.eltdf-sp-close'),
          
        if (popupOpener.length) {
            var popupPreventHolder = popupOpener.find('.eltdf-sp-prevent'),
                disabledPopup = 'no';
            
            if (popupPreventHolder.length) {
                var isLocalStorage = popupOpener.hasClass('eltdf-sp-prevent-cookies'),
                    popupPreventInput = popupPreventHolder.find('.eltdf-sp-prevent-input'),
                    preventValue = popupPreventInput.data('value');
                
                if (isLocalStorage) {
                    disabledPopup = localStorage.getItem('disabledPopup');
                    sessionStorage.removeItem('disabledPopup');
                } else {
                    disabledPopup = sessionStorage.getItem('disabledPopup');
                    localStorage.removeItem('disabledPopup');
                }
                
            ....jQuery);

2 个答案:

答案 0 :(得分:0)

更改

$(window).load(eltdfOnWindowLoad);

setTimeout(function(){
    eltdfOnWindowLoad();
}, 30000);

答案 1 :(得分:0)

感谢更新! #Ramiz Kongulov

<td>  {{ room.reservation_set.all|check_reservation:'time_now' }} </td>

我在.js中使用了这样的代码,但是延迟又是一样的吗?