javascript: getting two sibling windows communicate
Posted
by romuwild
on Stack Overflow
See other posts from Stack Overflow
or by romuwild
Published on 2010-02-10T12:49:21Z
Indexed on
2010/03/27
19:53 UTC
Read the original article
Hit count: 188
JavaScript
|html5
i have 2 windows: window A and window B.
-window A and window B have same domain
-window A and window B doesn't have any parent window.
first question:
-is it possible for window A to get a reference of window B?
second question:
-what is the most elegant way to make window A notify something to window B?
(modern browser supporting HTML5 restriction is not a problem)
2 ways i am aware of doing this:
-messaging by server: where window B regulary asks the server if window A has notified something
-messaging by local data (HTML5): when window A wants to notify something it changes the local data, window B regulary checks the local data for any change.
but the 2 ways are not so elegant.
for example it would be nice to get an reference of window B and using window.postMessage() (HTML5)
ultimate goal is to make something like facebook where if you open 4 facebook tabs, and chat in one tab, the chat is actualized on every facebook tab, which is neat!
thanks folks!
© Stack Overflow or respective owner