Created
January 25, 2021 18:39
-
-
Save abha57/c034e95fa82a389223c99b6df26f5d21 to your computer and use it in GitHub Desktop.
document.visibilityState
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| How to check if a Browser Tab is active or not? 🔥 | |
| 0. Stop video if the user changes the browser tab | |
| 1. Reduce Polling Rate of Data from API | |
| 2. Stop music if the user moves out | |
| document.visibilityState | |
| // 'visible' | |
| document.addEventListener("visibilitychange", function() { | |
| console.log( document.visibilityState ); | |
| // Modify behavior... | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment