Short answer:
You cannot truly pass state information from one tab to another...
Long answer:
You cannot truly pass state information from one tab to another, as this would be a very severe breach of sandboxing and security.
You can, however indirectly pass state between two tabs by way of:
Another option would to simply communicate via cookies to pass information between 2 tabs, but this would most likely cause issues, be highly browser-dependent and require page reloads (and to be honest I've never tried that one and just thought of it, but others have done it).
So, as browser extensions are obviously a fairly limiting path, you should go the way of client-server communications and develop a system to allow clients to publish events to a server, that then re-dispatches them (or any other kind of broadcast) to other clients via a communication protocol of your choice.
Update 1: As someone mentioned in a comment before removing it (cannot give credit as it doesn't show in the inbox, sorry)
HTML5 introduces the window.postMessage
API.
For a working example, see John Resig's blog-post on Cross-Window Messaging.
And very interestingly, if you look at the comments on this post you'll notice someone called Malte mentioning a library they wrote to use window.postMessage
on modern browsers, or a cookie-based version on older browsers.
Read these for more details and examples:
Update 2:
Keep in mind that, as 2012-03-04, the HTML5 specification is still a draft, so some features could be removed. So use with care...
HTTP is great (and beutiful) because it is stateless
. Ever since i joined industry, i am in search of that beuty but cann't quite find it. Everyone talks only about keeping the states you see! – Dipan Mehta Mar 4 '12 at 5:04