Web/API/WindowClient/visibilityState

From Get docs


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".

Syntax

var myVisState = windowClient.visibilityState;

Value

A DOMString (See Document.visibilityState for values).

Example

event.waitUntil(clients.matchAll({
    type: "window"
  }).then(function(clientList) {
    for (let i = 0; i < clientList.length; i++) {
      let client = clientList[i];
      if (client.url == '/' && 'focus' in client) {
        if (client.visibilityState === 'hidden')
          return client.focus();
        }
      }
    }

    if (clients.openWindow) {
      return clients.openWindow('/');
    }
  }));
});

Specifications

Specification Status Comment
Service WorkersThe definition of 'visibilityState' in that specification. Working Draft Initial definition.

Browser compatibility

Update compatibility data on GitHub

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet

visibilityState

Experimental'

Chrome

Full support 42

Edge

Full support ≤18

Firefox Full support 44

Notes'

Full support 44

Notes'

Notes' Extended Support Releases (ESR) before Firefox 78 ESR do not support service workers and the Push API.

IE

No support No

Opera

?

Safari

No support No

WebView Android

No support No

Chrome Android

Full support 42

Firefox Android

Full support 44

Opera Android

?

Safari iOS

No support No

Samsung Internet Android

Full support 4.0

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
Experimental. Expect behavior to change in the future.'
Experimental. Expect behavior to change in the future.
See implementation notes.'
See implementation notes.