Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

There are a few new HTML5 features that have made it into recent browsers that a

ID: 661395 • Letter: T

Question

There are a few new HTML5 features that have made it into recent browsers that allow sharing state among tabs, browser windows, same domain windows, etc. So it's probably gotten a little easier to write a web application that keeps a lot of state on the client and also manages state intelligently between tabs and/or windows.

There are currently libraries like Backbone.js that can help manage state in a single tab or a single window. Is there anything out there yet that helps with multiple tabs (or windows) managing global state, tab specific state, and cross-tab eventing without relying on the server to sync them all up?

Explanation / Answer

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:

client-server communications (WebSockets, AJAX calls, ...),
browser extensions (they can be allowed to bypass, and some browsers offer APIs to implement a message-passing system to communicate between background pages, tabs and content scripts),
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.