4

有没有人可以给我一些关于如何使用javascript处理窗口到窗口通信的想法,因为这两个窗口没有父子关系。基本上另一个窗口是使用 window.open 方法打开的。非常感谢任何精彩的信息。

4

1 回答 1

9

假设如下:

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

您可以在两个窗口之间进行交互。

您从使用变量名打开它的文档中有一个指向窗口对象的指针:

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

并从新窗口内的文档到打开新窗口的窗口,使用opener-property:

//doSomething has to be known inside the window that opened the new window
opener.doSomething();
于 2011-01-04T02:38:09.690 回答