Is there anyone who can give me some thoughts on how to handle window to window communication using javascript givin that the two windows has no parent child relationship. Basically the other window is opened using window.open method. Any brilliant information is well appreciated.
Asked
Active
Viewed 4,926 times
1 Answers
9
assuming the following:
windowHandle=window.open('path/to/document');
you can interact between both windows.
You have a pointer to the window-object from the document where it was opened from using the variable-name:
//doSomething has to be known inside the new window
windowHandle.doSomething();
and from the document inside the new window to the window that opened the new window, using the opener
-property:
//doSomething has to be known inside the window that opened the new window
opener.doSomething();

Dr.Molle
- 116,463
- 16
- 195
- 201
-
nice, but can't call any method as it will give the error `DOMException: Blocked a frame with origin from accessing a cross-origin frame.` and setting `Access-Control-Allow-Origin` won't help. How to do some communication between the windows? – brauliobo May 15 '15 at 00:10
-
the answer is `opener.postMessage()`, found on http://stackoverflow.com/questions/24603580/how-can-i-access-the-dom-elements-within-an-iframe – brauliobo May 15 '15 at 00:34