ServiceWorkerGlobalScope.oninstall
Experimental: これは実験的な機能です。
本番で使用する前にブラウザー互換性一覧表をチェックしてください。
ServiceWorkerGlobalScope
インターフェースの oninstall プロパティは、(Service Worker がインストールされたときの)install
イベントが発生するたびに発火するイベントハンドラーです。これはアクティブ化の前に発生します。
構文
ServiceWorkerGlobalScope.oninstall = function(event) { ... };
ServiceWorkerGlobalScope.addEventListener('install', function(event) { ... });
例
次のスニペットは Using Service Workers のものです。詳細はそちらをご覧ください。
this.addEventListener('install', function(event) {
event.waitUntil(
caches.create('v1').then(function(cache) {
return cache.add(
'/sw-test/',
'/sw-test/index.html',
'/sw-test/style.css',
'/sw-test/app.js',
'/sw-test/image-list.js',
'/sw-test/star-wars-logo.jpg',
'/sw-test/gallery/',
'/sw-test/gallery/bountyHunters.jpg',
'/sw-test/gallery/myLittleVader.jpg',
'/sw-test/gallery/snowTroopers.jpg'
);
})
);
});
仕様
仕様 | ステータス | コメント |
---|---|---|
Service Workers Event Handlers の定義 |
草案 | 初期定義。 |
ブラウザー実装状況
No compatibility data found for api.ServiceWorkerGlobalScope.oninstall
.
Check for problems with this page or contribute missing data to mdn/browser-compat-data.