The storage event of the Window interface fires when a storage area (localStorage or sessionStorage) 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

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
storage eventChrome No support NoEdge Full support YesFirefox Full support 45IE ? Opera ? Safari ? WebView Android No support NoChrome Android No support NoFirefox Android Full support 45Opera Android ? Safari iOS ? Samsung Internet Android ?

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown

See also

Document Tags and Contributors

Last updated by: chrisdavidmills,