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

前端 未结 5 1313
广开言路
广开言路 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:21

    var newWindow = null;
    
    function openwindow()
    {
      // open the new window only if newWindow is null (not opened yet)
      // or if it was closed
      if ((newWindow == null) || (newWindow.closed))
        newWindow = window.open(...);
    }
    

提交回复
热议问题