[英]JavaScript communication between 2 windows
I am using window.open
to open 2 new windows from my web page and these 2 new windows are of different domains. 我正在使用
window.open
从我的网页中打开2个新窗口,这2个新窗口属于不同的域。 My requirement is that from one window I want to change the URL of the other window and vice versa. 我的要求是,我想从一个窗口更改另一个窗口的URL,反之亦然。 Is there any way to achieve this?
有什么办法可以做到这一点?
Yes, this is possible. 是的,这是可能的。 Have a look at window.postMessage .
看看window.postMessage 。
The syntax looks like: 语法如下:
otherWindow.postMessage(message, targetOrigin, [transfer]);
Where otherWindow
is a reference to another window. 其中
otherWindow
是对另一个窗口的引用。 window.open
returns such a reference. window.open
返回这样的引用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.