ServiceWorkerRegistration.index
利用可能性は限定的
この機能はベースラインではありません。最も広く使用されているブラウザーの一部で動作しません。
Experimental: これは実験的な機能です。
本番で使用する前にブラウザー互換性一覧表をチェックしてください。
index は ServiceWorkerRegistration インターフェイスの読み取り専用プロパティで、オフラインコンテンツの索引付けができる ContentIndex インターフェイスへの参照を返します。
値
ContentIndex オブジェクトです。
例
このプロパティはメインスクリプトと登録済みサービスワーカーのどちらからでもアクセスできます。
ここでは、メインスクリプトからアクセスする例を示します。
js
// reference registration
const registration = await navigator.serviceWorker.ready;
// feature detection
if ("index" in registration) {
// Content Index API functionality
const contentIndex = registration.index;
}
サービスワーカーからの呼び出し例です。
js
// service worker script
const contentIndex = self.registration.index;
仕様書
| 仕様書 |
|---|
| Content Index> # dom-serviceworkerregistration-index> |