Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Window to Window Communication in js by window name

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.

like image 901
user561978 Avatar asked Jan 20 '23 19:01

user561978


1 Answers

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();
like image 151
Dr.Molle Avatar answered Jan 26 '23 10:01

Dr.Molle