Name

StorageEvent

Inherits from

Event

Synopsis

The localStorage and sessionStorage properties of a Window object refer to Storage objects that represent client-side storage areas (see localStorage and sessionStorage). If more than one window, tab, or frame is displaying documents from the same origin, multiple windows have access to the same storage areas. If a script in one window changes the contents of a storage area, a storage event is triggered on all other Window objects that share access to that storage area. (Note that the event is not triggered in the window that made the change.) Storage events are triggered on the Window object and do not bubble. They do not have any default action that can be canceled. The object associated with a storage event is a StorageEvent object, and its properties describe the change that occurred to the storage area.

Properties

readonly string key

This property is the key that was set or deleted. If the entire storage area was cleared with Storage.clear(), this property (as well as newValue and oldValue) will be null.

readonly any newValue

The new value of the specified key. This will be null if the key was removed. At the time of this writing, browser implementations only allow string values to be stored.

readonly any oldValue

The old value of the key that was changed, or null if this key was newly added to the storage area. At the time of this writing browser implementations only allow string values to be stored.

readonly Storage storageArea

This property ...

Get JavaScript: The Definitive Guide, 6th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.