onstorage 特性为 WindowEventHandlers 混合 EventHandler 为处理 storage 事件。

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 函数表达式 . 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 + '.');
};
					

规范

规范 状态 注释
HTML 实时标准
The definition of 'onstorage' in that specification.
实时标准

浏览器兼容性

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. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
onstorage Chrome 1 Edge ≤18 Firefox 45 IE ? Opera 15 Safari ? WebView Android ≤37 Chrome Android 18 Firefox Android 45 Opera Android 14 Safari iOS ? Samsung Internet Android 1.0

图例

完整支持

完整支持

兼容性未知 ?

兼容性未知

另请参阅

元数据

  • 最后修改: