WindowEventHandlers.onstorage
WindowEventHandlers.onstorage
属性包含一个在storage (en-US)
事件触发时的事件句柄。
注意:该事件不在导致数据变化的当前页面触发(如果浏览器同时打开一个域名下面的多个页面,当其中的一个页面改变 sessionStorage
或 localStorage
的数据时,其他所有页面的 storage
事件会被触发,而原始页面并不触发 storage
事件)
语法
windowObj.onstorage = function() { ... };
用例
window.onstorage = function(e) {
console.log( e.key + ' 键已经从 ' + e.oldValue + ' 改变为 ' + e.newValue + '.');
};
说明书
Specification | Status | Comment |
---|---|---|
HTML Living Standard onstorage |
Living Standard |
浏览器兼容性
No compatibility data found for api.WindowEventHandlers.onstorage
.
Check for problems with this page or contribute missing data to mdn/browser-compat-data.