Skip to content

Latest commit

 

History

History
16 lines (12 loc) · 380 Bytes

isBrowserTabFocused.md

File metadata and controls

16 lines (12 loc) · 380 Bytes
title tags
isBrowserTabFocused
browser,beginner

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.
const isBrowserTabFocused = () => !document.hidden;
isBrowserTabFocused(); // true