-8

Is there a way to get a popunder code when someone closes a site? I've searched on Google, but couldn't find a way or an answer.

Basically: user no longer wants to stay on a particular website, he it's close button ("x" button) and a popunder appears.

1 Answers1

-1
            window.onbeforeunload = function(event) {
            var message = 'Important: Please click on \'Save\' button to leave this page.';
            if ( typeof event == 'undefined') {
                event = window.event;
            }
            if (event) {
                event.returnValue = message;
            }
            return message;
        };

        $(function() {
            $("a").not('#lnkLogOut').click(function() {
                window.onbeforeunload = null;
            });
            $(".btn").click(function() {
                window.onbeforeunload = null;
            });
        });
Rajiv
  • 78
  • 10
  • First of all, don't give a jQuery answer when the question doesn't mention that they're using jQuery. Secondly, which part of this creates the popunder? – JJJ Apr 16 '16 at 17:51
  • Thirdly, this seems to have been copy-pasted from http://stackoverflow.com/a/20853978 without attribution. – JJJ Apr 16 '16 at 17:52