ServiceWorkerContainer.getRegistration()
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since April 2018.
getRegistration()
は ServiceWorkerContainer
インターフェイスのメソッドで、スコープ URL が指定された文書の URL と一致する ServiceWorkerRegistration
オブジェクトを取得します。 このメソッドは、ServiceWorkerRegistration
または undefined
に解決される Promise
を返します。
構文
js
getRegistration()
getRegistration(clientURL)
引数
clientURL
省略可-
この URL に照合するスコープを持つ登録が返されます。関連の URL は、現在のクライアントを基点として解決されます。この引数が指定されなかった場合、既定では現在のクライアントの URL が使用されます。
返値
ServiceWorkerRegistration
オブジェクトまたは undefined
に解決される Promise
です。
例
js
navigator.serviceWorker.getRegistration("/app").then((registration) => {
if (registration) {
document.querySelector("#status").textContent =
"ServiceWorkerRegistration が見つかりました。";
}
});
仕様書
Specification |
---|
Service Workers # navigator-service-worker-getRegistration |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
getRegistration |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.