javascript - How to tell if the user has switched to the current tab?
三叔2017-07-05 10:38:13
0
2
888
I noticed that YouTube will only start playing the video when the user switches to the current tab. So when a user opens multiple tabs, how to determine whether the user has switched to the current tab?
There is a Page Visibility API, you can take a look
I have thought about this implementation before, but it actually has shortcomings. What if sometimes I just want to listen to the sound? (:evil