forum

Home / DeveloperSection / Forums / Jquery Show Popup on window closing

Jquery Show Popup on window closing

Anonymous User215331-Oct-2014

I am trying to display a confirmation message when the user closes the browser/tab and not when any of the links on page is clicked.

I have got the first part of displaying the message on window close working nicely but problem is that the message/alert is displayed also when user clicks on any link on the page.

I have got code from somewhere to prevent this behavior but still when ever any link is clicked the alert pops up.

Here is the code:

<scriptsrc="js/jquery-1.7.1.min.js"></script>
<scriptsrc="js/jquery-ui.min.js"></script>
<scripttype="text/javascript"src="js/backfix-min.js"></script>
<script>
    $(document).ready(function () {
        $(window).bind('beforeunload', function (e) {
            $("#lead-gen-modal").dialog("open");
            return"Wait\! Don\'t Go\! We have a special offer for you\. Stay on this page to receive big savings\!";
        });
 
        $("a").click(function () {
            window.onbeforeunload = null;
        });
    });
</script>


Updated on 31-Oct-2014
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By