StorageEvent

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

Method overview

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
);
					

属性

属性 Type 描述
key DOMString Represents the key changed. The key attribute is 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 when the key has been newly added and therefore doesn't have any previous value. Read only.
storageArea Storage Represents the Storage object that was affected. Read only.
url USVString The URL of the document whose key changed. 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 可选
A boolean indicating whether the event is 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 可选
Storage object representing the storage area on which this event occurred.

规范

规范 Statuc Comment
HTML Living Standard
The definition of 'The StorageEvent interface' in that specification.
实时标准

浏览器兼容性

更新 GitHub 上的兼容性数据
Desktop Mobile
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

图例

完整支持
完整支持
兼容性未知
兼容性未知
非标。预期跨浏览器支持较差。
非标。预期跨浏览器支持较差。