The storage event 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:

  document.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
Storage
The definition of 'dblclick' in that specification.
Living Standard

Browser compatibility

No compatibility data found. Please contribute data for "api.document.defaultView.storage" (depth: 1) to the MDN compatibility data repository.

See also

Document Tags and Contributors

Last updated by: ecancino,