Refresh parent window when the pop-up window is closed

后端 未结 4 1866
梦如初夏
梦如初夏 2020-12-14 12:31

Is there any way I can refresh the parent window when a popup window is closed without adding any javascript code to the popup window?

I have a page parent.php on wh

4条回答
  •  天涯浪人
    2020-12-14 12:47

    The problem with Tim Down's method is that it doesn't answer the original question. The requirement is that you cannot add any code to the pop-up window.

    One solution that I've found, while not particularly elegant, is effective across all browsers I've tested on.

    You will be simply polling the newly created window object continuously, checking if it's still open.

    On parent window:

      var register;
      var poll;
    
      function isOpen(){
          if(register.closed){alert("Closed!"); clearInterval(poll);}
      }
    
    
      function create(){
    
          register = window.open("http://www.google.com","register","width=425,height=550");
          poll=setInterval("isOpen()",100); //Poll every 100 ms.
    }
    

提交回复
热议问题