Window: storage event

The storage event of the Window interface fires when a storage area (localStorage) has been modified in the context of another document.

Bubbles No
Cancelable No
Interface StorageEvent
Event handler property onstorage

Examples

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

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:

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

Specifications

Specification Status
HTML Living Standard
The definition of 'storage' in that specification.
Living Standard

Browser compatibility

DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
storage eventChrome Full support 1Edge Full support ≤18Firefox Full support 45IE ? Opera Full support 15Safari ? WebView Android Full support ≤37Chrome Android Full support 18Firefox Android Full support 45Opera Android Full support 14Safari iOS ? Samsung Internet Android Full support 1.0

Legend

Full support
Full support
Compatibility unknown
Compatibility unknown

See also