Redirect popup on main window close

A pop up is opened when a user clicks a button. This pop up will go to a holding page, and wait for the user to leave the website or close the browser.

Then when the user leaves or closes the browser, it will redirect the pop up location to a different site.

I have tried several variants of the following code:'','popup'); //just to illustrate the "win" = my

$(window).bind('beforeunload', function() {"";
   //tried something like this as well:

But without luck. I am not brilliant with javascript /jquery so any help on how to make this work would be deeply appreciated.




I know you already have a prototype working, but if you want the jquery option:

var popup ='', 'popup');

$(window).unload(function() {
    if(!popup.closed) {
        popup.location.href = '';

You should also be checking to see if popup.closed is there.


I found a solution:'','popup');

window.onunload = redirect;
function redirect(){"";


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.