javascript - Check if a popup window is already open before opening it using Jquery -
i want check if popup window open , before open popup window. how done using jquery?
below code open new popup window :
window.open("mystopchat.php?stat=1&session="+data['myid1']['session_id'][i],"win1","width=500,height=500"); now before call this, want sure popup window not open.
this little trick use, perhaps use it:
var winref; //this holds reference page, see later open or not function openwindow() { var url = //your url; if (typeof (winref) == 'undefined' || winref.closed) { //create new, since none open winref = window.open(url, "_blank"); } else { try { winref.document; //if throws exception have no access child window - domain change open new window } catch (e) { winref = window.open(url, "_blank"); } //ie doesn't allow focus, close , open new 1 if (navigator.appname == 'microsoft internet explorer') { winref.close(); winref = window.open(url, "_blank"); } else { //give focus better user experience winref.focus(); } } } hope helps.
Comments
Post a Comment