1

I want to make a POPUP div when user clicks on close window button.

At the moment i have this code:

JS:

<script type="text/javascript">

function PopIt() { 
    $("a#trigger").trigger('click');
    window.onbeforeunload = UnPopIt;
    return "Would you like to join our mailing list for other offers?"; 
}

function UnPopIt()  { /* nothing to return */ } 

$(document).ready(function() {
    window.onbeforeunload = PopIt;

    $("a#trigger").fancybox({
        'hideOnContentClick': false,
        'showCloseButton': false
    });

    $("a[id!=trigger]").click(function(){ window.onbeforeunload = UnPopIt; });
});

<div style="display: none;">
    <a id="trigger" href="#popup">&nbsp;</a>
    <div id="popup" style="width: 250px; height: 400px;">
        <p>This would be an aweber form.</p>
    </div>
</div>

It works, but not really the way I need. It popups the standard browser box with two buttons, stay or leave. I want to popup the div with id POPUP.

Please, can some one help me to fix my code?

FIDDLE

Thank you!

Andrei
  • 497
  • 2
  • 8
  • 18

0 Answers0