The onstorage
property of the WindowEventHandlers
mixin is an event handler for processing storage
events.
The storage
event fires when a storage area has been changed in the context of another document.
window.onstorage = functionRef;
functionRef
is a function name or a function expression. This function receives a StorageEvent
as its sole argument.
This example logs the value for a storage key whenever it changes in another document.
window.onstorage = function(e) { console.log('The ' + e.key + ' key has been changed from ' + e.oldValue + ' to ' + e.newValue + '.'); };
Specification |
---|
HTML Standard (HTML) # handler-window-onstorage |
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
onstorage |
1 |
15 |
45 |
9 |
15 |
4 |
≤37 |
18 |
45 |
14 |
4 |
1.0 |
© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onstorage