Web/API/Window/storage event

From Get docs


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 StandardThe definition of 'storage' in that specification. Living Standard

Browser compatibility

Update compatibility data on GitHub

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
storage event Chrome

Full support 1

Edge

Full support ≤18

Firefox

Full support 45

IE

?

Opera

Full support 15

Safari

?

WebView Android

Full support ≤37

Chrome Android

Full support 18

Firefox Android

Full support 45

Opera Android

Full support 14

Safari iOS

?

Samsung Internet Android

Full support 1.0

Legend

Full support  
Full support
Compatibility unknown  
Compatibility unknown


See also