Javascript 时事通讯弹出窗口延迟

Javascript 时事通讯弹出窗口延迟,javascript,php,html,magento,Javascript,Php,Html,Magento,我需要帮助来实现这一目标 我有一个magento模板,我的支持期已经到期,但我偶然发现一个问题,我不能真正正确地纠正 每当我的网站加载时,时事通讯会在同一时间弹出,这很烦人。我想要的是在站点完成加载后,新闻稿弹出窗口的延迟。如果可能的话,让它在用户会话中只出现一次 如果我能在这里得到帮助,我会很高兴的 非常感谢大家 下面是代码 <?php /** Made by Smartwave. */

我需要帮助来实现这一目标

我有一个magento模板,我的支持期已经到期,但我偶然发现一个问题,我不能真正正确地纠正

每当我的网站加载时,时事通讯会在同一时间弹出,这很烦人。我想要的是在站点完成加载后,新闻稿弹出窗口的延迟。如果可能的话,让它在用户会话中只出现一次

如果我能在这里得到帮助,我会很高兴的

非常感谢大家

下面是代码

            <?php
            /**
             Made by Smartwave.
             */
            ?>
            <?php
                $store = Mage::app()->getStore();
                $code  = $store->getCode();
                $popup = Mage::getStoreConfig('porto_settings/newsletter_popup',$code);
            ?>
            <script type="text/javascript">
                jQuery(function($) {
                    var check_cookie = $.cookie('newsletter_popup');
                    if(check_cookie == null || check_cookie == 'shown') {
                        beginNewsletterForm();
                    }
                    $('#newsletter_popup_dont_show_again').on('change', function(){
                        if($(this).length){        
                            var check_cookie = $.cookie('newsletter_popup');
                            if(check_cookie == null || check_cookie == 'shown') {
                                $.cookie('newsletter_popup','dontshowitagain');            
                            }
                            else
                            {
                                $.cookie('newsletter_popup','shown');
                                beginNewsletterForm();
                            }
                        } else {
                            $.cookie('newsletter_popup','shown');
                        }
                    }); 
                });

            function beginNewsletterForm() {
                jQuery.fancybox({
                    'padding': '0px',
                    'autoScale': true,
                    'transitionIn': 'fade',
                    'transitionOut': 'fade',
                    'type': 'inline',
                    'href': '#newsletter_popup',
                    'onComplete': function() {
                        $.cookie('newsletter_popup', 'shown');
                    },
                    'tpl': { 
                        closeBtn: '<a title="Close" class="fancybox-item fancybox-close fancybox-newsletter-close" href="javascript:;"></a>' 
                    }
                });
                jQuery('#newsletter_popup').trigger('click');
            }

            </script>
            <style type="text/css">
            <?php
                if($popup["newsletter_custom_style"]){
                    echo $popup["newsletter_custom_style"];
                }
            ?>
            #newsletter_popup{
            <?php
                if($popup["newsletter_width"]){
                    echo "width:".$popup["newsletter_width"].";";
                }
                if($popup["newsletter_height"]){
                    echo "height:".$popup["newsletter_height"].";";
                }
                if($popup["newsletter_bg_color"]){
                    echo "background-color:".$popup["newsletter_bg_color"].";";
                }
                if(isset($popup["newsletter_bg_image"]) && $popup["newsletter_bg_image"]){
            ?>
                background-image:url(<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA)."porto/newsletter_popup/".$popup['newsletter_bg_image'];?>);
            <?php
                }
            ?>
            }
            </style>
            <div class="block block-subscribe" id="newsletter_popup">
                <form action="<?php echo $this->getFormActionUrl() ?>" method="post" id="newsletter-popup-validate-detail" onsubmit="setNewsletterCookie()">
                    <div class="block-content">
                        <?php
                            if($popup["show_logo"]){
                        ?>
                                <img src="<?php echo $this->getSkinUrl($popup["show_logo"]); ?>" alt="" />
                        <?php
                            }
                        ?>
                        <?php echo $popup['newsletter_content']; ?>
                        <div class="input-box">
                            <input type="text" name="email" id="newsletter_popup_email" title="<?php echo $this->__('Sign up for our newsletter') ?>" class="input-text required-entry validate-email" placeholder="<?php echo $this->__("Email Address"); ?>" />
                            <button type="submit" title="<?php echo $this->__('Go!') ?>" class="button"><span><span><?php echo $this->__('Go!') ?></span></span></button>
                            <div class="clearer"></div>
                        </div>
                    </div>
                </form>
                <script type="text/javascript">
                //<![CDATA[
                    var newsletterpopupSubscriberFormDetail = new VarienForm('newsletter-popup-validate-detail');
                    document.getElementById("newsletter-popup-validate-detail").onsubmit=function(){
                        jQuery.cookie('newsletter_popup','dontshowitagain');
                    }
                //]]>
                </script>
                <div class="subscribe-bottom">
                    <input type="checkbox" id="newsletter_popup_dont_show_again"/>
                    <label for="newsletter_popup_dont_show_again"><?php echo $this->__("Don't show this popup again"); ?></label>
                </div>
            </div>
您可以使用php睡眠函数 欺骗: 如果它在页面中的中间,HTML以1秒的延迟呈现,则页面将花费1秒更长的时间来渲染。 将其放在页面底部

使用javascript,您可以使用:

setTimeout(function(){ }, 1000);

一秒钟的延迟

是的,你不能用PHP来实现这一点。寻找javascript的延迟函数