aboutsummaryrefslogtreecommitdiff
path: root/files/fr/web/api/windowclient/visibilitystate/index.md
blob: 3589b09443bf2d7e67bc2ea86efb907143f3d73d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
---
title: WindowClient.visibilityState
slug: Web/API/WindowClient/visibilityState
translation_of: Web/API/WindowClient/visibilityState
---
{{SeeCompatTable}}{{APIRef("Service Workers API")}}

La propriété **`visibilityState`**,  en lecture seule de l'interface {{domxref("WindowClient")}} indique la visibilité du client courant. La valeur pourra être :  `hidden`, `visible`, `prerender`, or `unloaded`.

## Syntaxe

```js
myVisState = WindowClient.visibilityState;
```

### Value

une  {{domxref("DOMString")}}.

## Example

```js
  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) {
        if(visibilityState === 'hidden')
          return client.focus();
        }
      }
    }
    if (clients.openWindow)
      return clients.openWindow('/');
  }));
});
```

## Spécifications

| Specification                                                                                        | Status                               | Comment             |
| ---------------------------------------------------------------------------------------------------- | ------------------------------------ | ------------------- |
| {{SpecName('Service Workers', '#window-client-interface', 'WindowClient')}} | {{Spec2('Service Workers')}} | Initial definition. |

## Compatibilité des navigateurs

{{Compat("api.WindowClient.visibilityState")}}