0

I want to show a popup winodw before I closing my browser. Here is my code.I used following plugin

http://kbeezie.com/cross-browser-exit-pop/

here is the demonstration http://kbeezie.com/exitpop.html

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

but this code shows a "Would you like to join our mailing list for other offers?" question before showing the popup window. I want to remove that popup question and only show that popup window there.

Kevin John
  • 99
  • 1
  • 8
  • 1
    it is not possible, look at this question/ answer http://stackoverflow.com/questions/7560532/what-can-i-put-in-beforeunload – winner_joiner Jan 05 '15 at 08:35

1 Answers1

0

EDITED due to comments by OP.

You cannot use a custom onbeforeunload modal. It's a security measure that you cannot bypass.

Original answer:

Simply change the line that says return "Would you like to join our mailing list for other offers?"; to return "Your message goes here within the string";.

  • please check the demonstration link. – Kevin John Jan 05 '15 at 08:26
  • I have. Isn't your question how to remove the message and optionally change it to something else? –  Jan 05 '15 at 08:29
  • nope. There is two popup windows, when you see that question ,simply click that "stay on this page" button, after that there will also show the real popup. I want that SECOND popup instead of the question. In the other hand, I want only show that second window while we closing the browser. Thanks – Kevin John Jan 05 '15 at 08:32
  • If my answer successfully disclosed your question, please tick the green check mark to help future visitors of the site :) –  Jan 05 '15 at 11:06