I have a piece of code that opens a window with:
$("#authorization_link").click(function() {
win = window.open($(this).attr("href"),'width=800,height=600');
});
Now I want to run another block when window "win"
is closed. What is the event and how do I run code on its detection?
You must use intervals to check when/if the window was close Here is how you'll do it:
win = window.open($(this).attr("href"),'width=800,height=600');
function checkIfWinClosed(intervalID){
if(win.closed){
alert('windowsClosed');
clearInterval(intervalID);
}
}
var interval = setInterval(function(){
checkIfWinClosed(interval);
},1000);
And here is a working example in fiddle
Hope that helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With