I have two windows: window A and window B.
Questions:
Two ways i am aware of doing this:
But the two ways are not so elegant.
For example it would be nice to get a reference of window B and use 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 up to date in every facebook tab, which is neat!
I'm sticking to the shared local data solution mentioned in the question using localStorage
. It seems to be the best solution in terms of reliability, performance, and browser compatibility.
localStorage
is implemented in all modern browsers.
The storage
event fires when other tabs makes changes to localStorage
. This is quite handy for communication purposes.
References can be found here:
Webstorage
Webstorage - storage event