Two pages, one shelf: this page and a real same-origin iframe listen for the real storage event. Who hears when one of them writes? An interactive Cross-Tab…
Log out of every tab at once, a cart that follows along, a theme that catches up: the storage event gives cross-tab sync without a server. But its rules are strict: the writer never hears itself, the values are always strings or null, and a write that changes nothing tells nobody.
The storage event is for the other pages, and only for changes
storage event in the tab that just called setItem() The writing tab never gets its own event. Update its view right after setItem(), and count on the storage event for the other tabs.e.newValue is already an object Always a string, or null when the key was removed. Store with JSON.stringify, read with JSON.parse(e.newValue), and handle null first.sessionStorage or another origin to sync across tabs sessionStorage belongs to one tab: its events reach only other frames in the same tab. Another origin never hears; for that use postMessage, and for messages between tabs of one origin, BroadcastChannel.e.newValue.karung without JSON.parse undefined, or SyntaxError for an object stored as it is.