skip to Main Content

I’ve got a problem with simple popup newsletter in homepage…
Basically after I close the popup, if I refresh homepage, popup appears for about one second then disappear.

This is the code:

  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>

It seems that class "d-none" be applied only after all html loaded.
I would like to prevent newsletter appears for a second if I already close it….

2

Answers


  1. Chosen as BEST ANSWER

    Here the complete code I've found:

          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();
        }
    }
    

  2. Just semplified code, but still appears for a little moment…
    I don’t want appears again after closed…

    function popup() {
        if (!jQuery.cookie('brilliant_pop_newletter') || 
            jQuery.cookie('brilliant_pop_newletter') == null) {
                $('.jsclosepoup').on('click', function() {
                    jQuery.cookie('brilliant_pop_newletter', '1', {expires: 1, path:'/', domain: '{{shop.url}}' });
                $('.jsengo_popup').hide();
            });
        } else {
            $('.jsengo_popup').hide();
        }
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search