Javascript Sessionstorage Across Tabs?
I am using sessionStorage to ensure an action only happens once per session. However, if a user opens a new window - the sessionStorage is not carried over to the new window, and t
Solution 1:
As far as html5 storage goes i would go for localStorage in your case.
See below for the differences.
Session Storage:
- Values persist only as long as the window or tab in which they stored.
- Values are only visible within the window or tab that created them.
Local Storage:
- Values persist window and browser lifetimes.
- Values are shared across every window or tab running at the same origin.
Solution 2:
You probably want to switch to localStorage
as sessionStorage
is bound to individual tabs and localStorage
is not.
Solution 3:
If you're OK with targetting only FF/Chrome you might also want to take a look at the Broadcast Channel API
The Broadcast Channel API allows simple communication between browsing contexts (that is windows, tabs, frames, or iframes) with the same origin (usually pages from the same site).
Post a Comment for "Javascript Sessionstorage Across Tabs?"