问题
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. Basically the other window is opened using window.open method. Any brilliant information is well appreciated.
回答1:
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();
来源:https://stackoverflow.com/questions/4589963/window-to-window-communication-in-js-by-window-name