Window to Window Communication in js by window name

前端 未结 1 479
梦谈多话
梦谈多话 2021-01-19 06:42

Is there anyone who can give me some thoughts on how to handle window to window communication using javascript givin that the two windows has no parent child relationship. B

1条回答
  •  鱼传尺愫
    2021-01-19 07:30

    assuming the following:

    windowHandle=window.open('path/to/document');
    

    you can interact between both windows.

    You have a pointer to the window-object from the document where it was opened from using the variable-name:

    //doSomething has to be known inside the new window
    windowHandle.doSomething();
    

    and from the document inside the new window to the window that opened the new window, using the opener-property:

    //doSomething has to be known inside the window that opened the new window
    opener.doSomething();
    

    0 讨论(0)
提交回复
热议问题