javascript: getting two sibling windows communicate
- by romuwild
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!