From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../api/windoweventhandlers/onstorage/index.html | 98 ++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 files/zh-cn/web/api/windoweventhandlers/onstorage/index.html (limited to 'files/zh-cn/web/api/windoweventhandlers/onstorage') diff --git a/files/zh-cn/web/api/windoweventhandlers/onstorage/index.html b/files/zh-cn/web/api/windoweventhandlers/onstorage/index.html new file mode 100644 index 0000000000..fe7dc2a7cc --- /dev/null +++ b/files/zh-cn/web/api/windoweventhandlers/onstorage/index.html @@ -0,0 +1,98 @@ +--- +title: WindowEventHandlers.onstorage +slug: Web/API/WindowEventHandlers/onstorage +tags: + - API + - Web Storage + - WindowEventHandlers + - 属性 +translation_of: Web/API/WindowEventHandlers/onstorage +--- +
{{ ApiRef() }}
+ +

WindowEventHandlers.onstorage 属性包含一个在{{event("storage")}}事件触发时的事件句柄。 

+ +

注意:该事件不在导致数据变化的当前页面触发(如果浏览器同时打开一个域名下面的多个页面,当其中的一个页面改变 sessionStoragelocalStorage 的数据时,其他所有页面的  storage  事件会被触发,而原始页面并不触发 storage 事件)

+ +

语法

+ +
windowObj.onstorage = function() { ... };
+ +

用例

+ +
window.onstorage = function(e) {
+  console.log( e.key + ' 键已经从 ' + e.oldValue + ' 改变为 ' + e.newValue + '.');
+};
+ +

说明书

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG','webappapis.html#handler-window-onstorage','onstorage')}}{{Spec2('HTML WHATWG')}}
+ +

浏览器兼容性

+ +

{{CompatibilityTable}}

+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Basic support{{CompatUnknown}}{{CompatGeckoDesktop(45)}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidAndroid WebviewFirefox Mobile (Gecko)Firefox OSIE MobileOpera MobileSafari MobileChrome for Android
Basic support{{CompatUnknown}}{{CompatUnknown}}{{CompatGeckoMobile(45)}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
+
-- cgit v1.2.3-54-g00ecf