Jquery: How To Detect If Popup Window Is Closed?
I want to detect if the user pressed the browser's close button on a popup window in my application. By searching around I found this solution: $(window).bind('beforeunload',
Solution 1:
Can you try this, You can use the below code to check the browser popup closed status.
var yourwindowname; // add in Global /*Added this for to open a browser popup window */if(yourwindowname==undefined){
var param= "toolbar=no,scrollbars=1";
yourwindowname=window.open("your url here", 'yourwindowname', param);
}else{
yourwindowname.focus();
}
/* Added this to Check the popup closed status - In your case on ajax success event */var timer = setInterval(function() {
if(yourwindowname.closed) {
clearInterval(timer);
//do your process herealert("Popup Closed");
}else{
yourwindowname.close();
}
}, 1000);
Updated code for your working project: Use the below code instead of your current javascript functions.
functionpopup (url) {
if(win==undefined){
win = window.open(url, "Fenster", "width=1200,height=600,resizable=yes,menubar=no,toolbar=no,status=no,location=no,directories=no");
}else{
win.focus();
}
returnfalse;
}
functioncheckWindowClosed(){
var timer = setInterval(function() {
if(win.closed) {
clearInterval(timer);
progress();
alert("Popup Closed");
}else{
win.close();
}
}, 1000);
}
$.ajax({
type: "POST",
url: "acquisition_cleanup.php",
data: dataStr,
success: function () {
checkWindowClosed();
}
});
Post a Comment for "Jquery: How To Detect If Popup Window Is Closed?"