简体   繁体   中英

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. My requirement is that from one window I want to change the URL of the other window and vice versa. Is there any way to achieve this?

Yes, this is possible. Have a look at window.postMessage .

The syntax looks like:

otherWindow.postMessage(message, targetOrigin, [transfer]);

Where otherWindow is a reference to another window. window.open returns such a reference.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM