Access a window by window name

后端 未结 7 1163
悲哀的现实
悲哀的现实 2020-11-29 07:08

If I open a window using

window.open(\'myurl.html\', \'windowname\', \'width=100,height=100\');

How do I refer to the new window (from the

7条回答
  •  [愿得一人]
    2020-11-29 07:52

    Sorry I am posting late, but if you still have the other window open, and they are on the same domain, you can run, on the first window:

    function getReference(w) {
       console.log('Hello from', w);
    }
    

    And on the second window:

    window.opener.getReference(window);
    

提交回复
热议问题