Check if a popup window is already open before opening it using Jquery

前端 未结 5 1314
广开言路
广开言路 2021-02-08 11:44

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 :

5条回答
  •  臣服心动
    2021-02-08 12:07

    var popup;
    function openPopupOneAtATime() {
        if (popup && !popup.closed) {
           popup.focus();
           /* or do something else, e.g. close the popup or alert a warning */
        }
        else {
           popup = window.open(...);      
        }
    }
    

提交回复
热议问题