【发布时间】:2020-05-24 15:31:28
【问题描述】:
我在 2 个窗口之间的通信中遇到问题我有窗口 P,它是父窗口。我使用 window.open('path',A); 打开新的 2 个新窗口(A,B);和 window.open('path',B)。现在我需要在 A 和 B 之间进行通信。请帮助 B/w A 和 B 进行通信。
我试过了,还是不行
// In A component
window.opener('A').postMessage(JSON.stringify(messageData), "*");
//In B component
window.addEventListener("message", this.receiveMessage.bind(this), false);
我也试过了,还是不行
// IN A component
window.open('','A').postMessage(JSON.stringify(messageData), "*");
// IN B component
window.addEventListener("message", this.receiveMessage.bind(this), false);
另外一个我用的 BroadCast 没用
【问题讨论】:
-
这个问题的状态如何?
-
我通过 postMessage 解决了这个问题
标签: javascript angular cross-browser broadcastreceiver window.open