From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../skipwaiting/index.html | 122 +++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 files/ja/web/api/serviceworkerglobalscope/skipwaiting/index.html (limited to 'files/ja/web/api/serviceworkerglobalscope/skipwaiting/index.html') diff --git a/files/ja/web/api/serviceworkerglobalscope/skipwaiting/index.html b/files/ja/web/api/serviceworkerglobalscope/skipwaiting/index.html new file mode 100644 index 0000000000..156a830fb1 --- /dev/null +++ b/files/ja/web/api/serviceworkerglobalscope/skipwaiting/index.html @@ -0,0 +1,122 @@ +--- +title: ServiceWorkerGlobalScope.skipWaiting() +slug: Web/API/ServiceWorkerGlobalScope/skipWaiting +tags: + - API + - Method + - Reference + - ServiceWorker + - skipWaiting +translation_of: Web/API/ServiceWorkerGlobalScope/skipWaiting +--- +
{{SeeCompatTable}}{{APIRef("Service Workers API")}}
+ +

{{domxref("ServiceWorkerGlobalScope")}} スコープの ServiceWorkerGlobalScope.skipWaiting() メソッドは、待機している Service Worker がアクティブになるように強制します。

+ +

このメソッドは、{{domxref("Clients.claim()")}} と併用することで、現在のクライアントと他のすべてのアクティブなクライアントの両方で、元となる Service Worker の更新が即座に有効になるようにします。

+ +

構文

+ +
ServiceWorkerGlobalScope.skipWaiting().then(function() {
+  //Do something
+});
+ +

戻り値

+ +

{{jsxref("Promise")}}。

+ +

+ +

次の例では、登録済みの Service Worker の新しいバージョンでインストールされている既存のものを置き換え、開いているページ上で現在アクティブな worker を入れ替えています。

+ +
self.addEventListener('install', function(event) {
+  event.waitUntil(self.skipWaiting());
+});
+self.addEventListener('activate', function(event) {
+  event.waitUntil(self.clients.claim());
+});
+
+ +

仕様

+ + + + + + + + + + + + + + +
仕様ステータスコメント
{{SpecName('Service Workers', '#service-worker-obj', 'ServiceWorker')}}{{Spec2('Service Workers')}}初期定義。
+ +

ブラウザー実装状況

+ +
{{CompatibilityTable}}
+ +
+ + + + + + + + + + + + + + + + + + + +
機能ChromeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
基本サポート{{CompatChrome(42.0)}}{{ CompatGeckoDesktop("44.0") }}[1]{{CompatNo}}{{CompatUnknown}}{{CompatNo}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
機能AndroidFirefox Mobile (Gecko)Firefox OSIE MobileOpera MobileSafari MobileChrome for Android
基本サポート{{CompatUnknown}}{{ CompatGeckoMobile("44.0") }}{{ CompatVersionUnknown }}{{CompatNo}}{{CompatUnknown}}{{CompatNo}}{{CompatChrome(42.0)}}
+
+ +

[1] Service worker(と Push)は、Firefox 45 延長サポート版(ESR)では使用できません。

+ +

関連項目

+ + -- cgit v1.2.3-54-g00ecf