WindowClient

open class WindowClient : Client(source)

The WindowClient interface of the ServiceWorker API represents the scope of a service worker client that is a document in a browsing context, controlled by an active worker. The service worker client independently selects and uses a service worker for its own loading and sub-resources.

MDN Reference

Properties

Link copied to clipboard

The focused read-only property of the WindowClient interface is a boolean value that indicates whether the current client has focus.

Link copied to clipboard

The frameType read-only property of the Client interface indicates the type of browsing context of the current Client. This value can be one of "auxiliary", "top-level", "nested", or "none".

Link copied to clipboard
val id: String

The id read-only property of the Client interface returns the universally unique identifier of the Client object.

Link copied to clipboard

The type read-only property of the Client interface indicates the type of client the service worker is controlling.

Link copied to clipboard
val url: String

The url read-only property of the Client interface returns the URL of the current service worker client.

Link copied to clipboard

The visibilityState read-only property of the WindowClient interface indicates the visibility of the current client. This value can be one of "hidden", "visible", or "prerender".

Functions

Link copied to clipboard
inline suspend fun WindowClient.focus(): WindowClient

The focus() method of the WindowClient interface gives user input focus to the current client and returns a Promise that resolves to the existing WindowClient.

Link copied to clipboard

The focus() method of the WindowClient interface gives user input focus to the current client and returns a Promise that resolves to the existing WindowClient.

Link copied to clipboard
inline suspend fun WindowClient.navigate(url: String): WindowClient?

The navigate() method of the WindowClient interface loads a specified URL into a controlled client page then returns a Promise that resolves to the existing WindowClient.

inline suspend fun WindowClient.navigate(url: URL): WindowClient?
Link copied to clipboard

The navigate() method of the WindowClient interface loads a specified URL into a controlled client page then returns a Promise that resolves to the existing WindowClient.

Link copied to clipboard
fun postMessage(message: String, transfer: ReadonlyArray<Transferable>)
fun postMessage(message: String, options: StructuredSerializeOptions = definedExternally)
fun postMessage(message: JsAny?, options: StructuredSerializeOptions = definedExternally)

fun postMessage(message: JsAny?, transfer: ReadonlyArray<Transferable>)

The postMessage() method of the Client interface allows a service worker to send a message to a client (a Window, Worker, or SharedWorker). The message is received in the message event on navigator.serviceWorker.