Client
インターフェイスの url
読み取り専用プロパティは、現在のサービスワーカークライアントの URL を返します。
構文
var clientUrl = client.url;
値
例
self.addEventListener('notificationclick', function(event) {
console.log('On notification click: ', event.notification.tag);
event.notification.close();
// これは、クライアントが既に開いているかどうかを確認し、
// 開いている場合にフォーカスを合わせます
event.waitUntil(clients.matchAll({
type: 'window'
}).then(function(clientList) {
for (var i = 0; i < clientList.length; i++) {
var client = clientList[i];
if (client.url == '/' && 'focus' in client)
return client.focus();
}
if (clients.openWindow)
return clients.openWindow('/');
}));
});
仕様
仕様 | 状態 | コメント |
---|---|---|
Service Workers url の定義 |
草案 | 初期定義 |
ブラウザーの互換性
BCD tables only load in the browser
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.