I want to check if a popup window is already open , before I open the popup window. How do I get it done using Jquery?
Below is my code to open a new popup window :
Here is my suggestion:
function authorize(callback) {
if(!document.authorize) {
console.log('Opening authorization window...');
document.authorize = window.open('popup.html','tw','width=300,height=200');
}
if(document.authorize.closed) {
console.log('Authorization window was closed...');
setTimeout(callback,0);
} else {
setTimeout(function(){
console.log('Authorization window still open...');
authorize(callback);
},1000);
}
return false;
}
function test() {
authorize(function(){
alert('teste');
});
}