Pop up with jquery before closing the browser [duplicate]

0

I would like to make a pop up that appears before the person closes the tab of the browser equal to that of the shoptime: link

I do not have much knowledge in Javascript, let alone in jquery. Can anyone help me?

    
asked by anonymous 29.06.2016 / 21:48

2 answers

1

You can do this with a plugin called OuiBounce .

After installing the plugin and calling it on the page, create a hidden div with an id for it, for example:

<div id="ouibounce-modal">
  <div class="modal">
    <div class="modal-title">
      <h3>Modal de Exemplo</h3>
    </div>

    <div class="modal-body">
      <p>Exemplo</p>

    <div class="modal-footer">
      <p>Fechar</p>
    </div>
  </div>
</div>

And call a javascript to assign the OuiBounce event to that div

var _ouibounce = ouibounce(document.getElementById('ouibounce-modal'), {
        aggressive: true,
        timer: 0,
        callback: function() {
           _ouibounce.disable();
        }
      });

  $('body').on('click', function() {
    $('#ouibounce-modal').hide();
  });
# Essa função vai fechar o modal quando eu clicar fora dele #

  $('#ouibounce-modal .modal-footer').on('click', function() {
    $('#ouibounce-modal').hide();
  });
# Essa função vai fechar o modal quando eu clicar no botão 'Fechar' #

  $('#ouibounce-modal .modal').on('click', function(e) {
    e.stopPropagation();
  });
# Essa função vai impedir o modal de ser fechado se eu clicar dentro dele #
    
01.07.2016 / 17:18
0

You can use fancybox , see below:

$(function() {

    var content = '<div id="conteudo" class="col-xs-12 col-md-12">Sua propaganda aqui!</div>';
    $.fancybox.open([{
                   type: 'inline',
                   autoScale: true,
                   minHeight: 30,
                   content: content,
                   closeBtn:true
                  }], { padding: 0 });
});
    
01.07.2016 / 19:04