The onstorage
property of the WindowEventHandlers
mixin is an EventHandler
for processing storage
events.
The storage
event fires when a storage area has been changed in the context of another document.
Syntax
window.onstorage = functionRef;
Value
functionRef
is a function name or a function expression. This function receives a StorageEvent
as its sole argument.
Example
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 + '.');
};
Specifications
Specification | Status | Comment |
HTML Living StandardThe definition of 'onstorage' in that specification. | Living Standard |
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Update compatibility data on GitHub
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
onstorage
|
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
WindowEventHandlers.onstorage by Mozilla Contributors is licensed under CC-BY-SA 2.5.