Find window previously opened by window.open

后端 未结 5 1723
攒了一身酷
攒了一身酷 2020-12-05 04:52

We\'ve got the following situation, running from a single domain:

Page A uses window.open() to open a named window (a popup player). window.open()

5条回答
  •  情书的邮戳
    2020-12-05 05:34

    AFAIK, no there isn't..

    A kind-of-dirty-but-i-guess-it-will-work hack would be to periodically reset the reference on the parent window from within the popup using window.opener, with something like this code:

    
        setInterval(function() {
            if(window.opener) {
                window.opener.document.myPopupWindow = window
            }
        }, 100)
    
    

    In the parent window, you'll be able to access document.myPopupWindow, even after a reload (well, 100ms after the reload). This should work cross browser.

提交回复
热议问题