Check if the current tab is in view / focus


PHOTO EMBED

Mon Jan 25 2021 14:10:20 GMT+0000 (UTC)

Saved by @aymanelya #javascript

const isBrowserTabInView = () => document.hidden;
isBrowserTabInView();
// Result: returns true or false depending on if tab is in view / focus
content_copyCOPY

https://medium.com/dailyjs/13-javascript-one-liners-thatll-make-you-look-like-a-pro-29a27b6f51cb