jQuery Capture Close of Popup Window

Sam Deering
Share

jQuery code snippet to Capture the Close of a Popup Window.

//monitor the closing of a popup window
var win = window.open("http://dev.com/index.php?m=social&a=testLinkedIn",'','height=500,width=500');
var winTimer = window.setInterval(function()
{
    if (win.closed !== false)
    {
        // !== is required for compatibility with Opera
        window.clearInterval(winTimer);
        log('win closed...');
    }
}, 200);