function checkwindow(win) { if(win.closed == true) { alert('closed'); } if(win.closed == false) { setTimeout(checkwindow, 1000); } }