function Unload(win, callback) { !function check () { if(win.closed){ callback.call(win); return; } setTimeout(check, 500); }(); };