javascript - 通过窗口名称在js中进行窗口到窗口通信

标签 javascript window communication window.open

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

最佳答案

假设如下:

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();

关于javascript - 通过窗口名称在js中进行窗口到窗口通信,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4589963/

相关文章:

javascript - 如何在不刷新 ASP.net 页面的情况下更新我的 Html 表单?

c# - 我想每秒显示数字时钟来刷新TextBox(Windows App)

java - 通过 USB 进行 Android Java 通信

linux - Linux下与scilab的串口通信

c++ - 两个应用程序可以通过 UDP 数据包进行通信吗?

javascript - 错误 : Failed to instantiate module restangular due to: '_' is undefined

javascript - 用javascript替换两个字段中的特殊字符

python - Kivy代码显示ListView崩溃

javascript - 将 JavaScript 变量拆分为 2 个,其中 X 分隔 2 个数字

forms - 显示另一个表单时防止出现主表单