GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • MDN
  • HTML: Markup language
  • Elements
  • Global attributes
  • Attributes
  • See all…
  • Responsive images
  • HTML cheatsheet
  • Date & time formats
  • See all…
  • SVG
  • MathML
  • XML
  • CSS: Styling language

This view

  • Original page
  • New address

GeezerVison is showing developer.mozilla.org — Window: storage event - Web APIs | MDN

Window: storage event

Baseline
Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since April 2017.

  • See full compatibility
  • Learn more

The storage event of the Window interface fires when another document that shares the same storage area (either localStorage or sessionStorage) as the current window updates that storage area. The event is not fired on the window that made the change.

  • For localStorage, the event is fired in all other browsing contexts that are in the same origin as the initiating document. This includes other tabs with the same origin.
  • For sessionStorage, the event is fired in all other browsing contexts that are in the same origin and the same top-level browsing context as the initiating document. This only includes embedded iframes, if any, in the same tab, and not other tabs.

This event is not cancelable and does not bubble.

Syntax

Use the event name in addEventListener():

js
addEventListener("storage", (event) => { })

Alternatively, assign to the event handler property of the interface:

js
onstorage = (event) => { }

Event type

A StorageEvent. Inherits from Event.

Event handler aliases

In addition to the Window interface, the event handler property onstorage is also available on the following targets:

  • HTMLBodyElement
  • HTMLFrameSetElement
  • SVGSVGElement

Examples

Log the sampleList item to the console when the storage event fires:

js
window.addEventListener("storage", () => {
  // When local storage changes, dump the list to
  // the console.
  console.log(JSON.parse(window.localStorage.getItem("sampleList")));
});

The same action can be achieved using the onstorage event handler property (but note that this replaces other event listeners added using onstorage, if any):

js
window.onstorage = () => {
  // When local storage changes, dump the list to
  // the console.
  console.log(JSON.parse(window.localStorage.getItem("sampleList")));
};

Specifications

Specification
HTML
# event-storage
HTML
# handler-window-onstorage

Browser compatibility

See also

  • Web Storage API
  • Using the Web Storage API
  • Responding to storage changes with the StorageEvent

Help improve MDN

Learn how to contribute

This page was last modified on Oct 26, 2026 by MDN contributors.

View this page on GitHub • Report a problem with this content
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.