Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
// Removed IE support in this demo for the sake of simplicity
(function() {
if (!sessionStorage.length) {
// Ask other tabs for session storage
// Core
window.addEventListener('storage', function(event) {
if (event.key == 'getSessionStorage') {
// Some tab asked for the sessionStorage -> send it
localStorage.setItem('sessionStorage', JSON.stringify(sessionStorage));
} else if (event.key == 'sessionStorage' && !sessionStorage.length) {
// sessionStorage is empty -> fill it
var data = JSON.parse(event.newValue),
for (key in data) {
sessionStorage.setItem(key, data[key]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.