Movatterモバイル変換


[0]ホーム

URL:


  1. 開発者向けのウェブ技術
  2. Web API
  3. WindowClient

このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docsコミュニティーについてもっと知り、仲間になるにはこちらから。

View in EnglishAlways switch to English

WindowClient

Baseline Widely available *

This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2018年4月.

* Some parts of this feature may have varying levels of support.

WindowClientサービスワーカー API のインターフェイスで、アクティブなワーカーによって制御される閲覧コンテキスト内のドキュメントである、サービスワーカークライアントのスコープを表します。 サービスワーカークライアントは、それ自身の読み込みとサブリソースに対してサービスワーカーを個別に選択して使用します。

Client WindowClient

インスタンスメソッド

WindowClient には、親インターフェイスであるClient から継承したメソッドがあります。

WindowClient.focus()

現在のクライアントにユーザー入力フォーカスを与えます。

WindowClient.navigate()

指定された URL を制御されたクライアントのページに読み込みます。

インスタンスプロパティ

WindowClient には、親インターフェイスであるClient から継承したプロパティがあります。

WindowClient.focused読取専用

論理値で、現在のクライアントにフォーカスがあるかどうかを示します。

WindowClient.visibilityState読取専用

現在のクライアントの可視性を示します。 この値は、"hidden""visible""prerender" のいずれかです。

js
self.addEventListener("notificationclick", (event) => {  console.log("On notification click: ", event.notification.tag);  event.notification.close();  // これは、クライアントが既に開いているかどうかを確認し、  // 開いている場合にフォーカスを合わせます  event.waitUntil(    clients      .matchAll({        type: "window",      })      .then((clientList) => {        for (const client of clientList) {          if (client.url === "/" && "focus" in client) {            client.focus();            break;          }        }        if (clients.openWindow) return clients.openWindow("/");      }),  );});

仕様書

Specification
Service Workers Nightly
# windowclient

ブラウザーの互換性

関連情報

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2026 Movatter.jp