Files
30-seconds-of-code/snippets/isBrowserTabFocused.md
2018-04-15 19:18:44 +03:00

14 lines
344 B
Markdown

### isBrowserTabFocused
Returns `true` if the browser tab of the page is focused, `false` otherwise.
Use the `Document.hidden` property, introduced by the Page Visibility API to check if the browser tab of the page is visible or hidden.
```js
const isBrowserTabFocused = () => !document.hidden;
```
```js
isBrowserTabFocused(); // true
```