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 Workers The definition of 'visibilityState' in that specification. |
Working Draft | Initial definition. |
Browser compatibility
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.
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
visibilityState | Chrome Full support 42 | Edge Full support ≤18 | Firefox
Full support
44
| 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.