A StorageEvent is sent to a window when a storage area it has access to is changed within the context of another document.

  <div id="interfaceDiagram" style="display: inline-block; position: relative; width: 100%; padding-bottom: 11.666666666666666%; vertical-align: middle; overflow: hidden;"><svg style="display: inline-block; position: absolute; top: 0; left: 0;" viewbox="-50 0 600 70" preserveAspectRatio="xMinYMin meet"><a xlink:href="../API/Event" target="_top"><rect x="1" y="1" width="75" height="50" fill="#fff" stroke="#D4DDE4" stroke-width="2px" /><text  x="38.5" y="30" font-size="12px" font-family="Consolas,Monaco,Andale Mono,monospace" fill="#4D4E53" text-anchor="middle" alignment-baseline="middle">Event</text></a><polyline points="76,25  86,20  86,30  76,25" stroke="#D4DDE4" fill="none"/><line x1="86" y1="25" x2="116" y2="25" stroke="#D4DDE4"/><a xlink:href="../API/StorageEvent" target="_top"><rect x="116" y="1" width="120" height="50" fill="#F4F7F8" stroke="#D4DDE4" stroke-width="2px" /><text  x="176" y="30" font-size="12px" font-family="Consolas,Monaco,Andale Mono,monospace" fill="#4D4E53" text-anchor="middle" alignment-baseline="middle">StorageEvent</text></a></svg></div>
					
  a:hover text { fill: #0095DD; pointer-events: all;}
					

方法概述

void initStorageEvent(
  in DOMString type,
  in boolean canBubble,
  in boolean cancelable,
  in DOMString key,
  in DOMString oldValue,
  in DOMString newValue,
  in USVString url,
  in Storage storageArea
);
					

属性

属性 类型 描述
key DOMString Represents the key changed. The key 属性为 null when the change is caused by the storage clear() 方法。 Read only.
newValue DOMString The new value of the key newValue is null when the change has been invoked by storage clear() method or the key has been removed from the storage. Read only.
oldValue DOMString The original value of the key oldValue is null key has been newly added and therefore doesn't have any previous value. Read only.
storageArea 存储 Represents the 存储 object that was affected. Read only.
url USVString The URL of the document whose key 改变。 Read only.

方法

initStorageEvent()

Initializes the event in a manner analogous to the similarly-named initEvent() method in the DOM Events interfaces.

句法

storageEvent.initStorageEvent(type[, canBubble[, cancelable[, key[, oldValue[, newValue[, url[, storageArea]]]]]]])
					
参数
typeArg

The name of the event.

canBubble 可选

A boolean indicating whether the event bubbles up through the DOM or not.

cancelable 可选

布尔指示事件是否可取消。

key 可选

The key whose value is changing as a result of this event.

oldValue 可选

The key's old value.

newValue 可选

The key's new value.

url 可选

The URL of the document initiating the change.

storageArea 可选
存储 object representing the storage area on which this event occurred.

规范

规范 Statuc 注释
HTML 实时标准
定义为 ' StorageEvent 接口' 在该规范中。
实时标准

浏览器兼容性

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
StorageEvent Chrome 1 Edge ≤18 Firefox Yes IE ? Opera Yes Safari Yes WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
StorageEvent() 构造函数 Chrome 17 Edge ≤79 Firefox Yes IE ? Opera Yes Safari 6 WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android Yes Safari iOS 6 Samsung Internet Android Yes
initStorageEvent 非标 Chrome Yes Edge 12 Firefox Yes IE ? Opera Yes Safari Yes WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
key Chrome 1 Edge 12 Firefox Yes IE ? Opera Yes Safari Yes WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
newValue Chrome 1 Edge 12 Firefox Yes IE ? Opera Yes Safari Yes WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
oldValue Chrome 1 Edge 12 Firefox Yes IE ? Opera Yes Safari Yes WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
storageArea Chrome 3 Edge 12 Firefox Yes IE ? Opera Yes Safari Yes WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
url Chrome 5 Edge 12 Firefox Yes IE ? Opera Yes Safari Yes WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android Yes

图例

完整支持

完整支持

兼容性未知 ?

兼容性未知

非标。预期跨浏览器支持较差。

非标。预期跨浏览器支持较差。

元数据

  • 最后修改: