javascript - Is there a way to detect if a browser window is not currently active?

Опубликовано: 07 Апрель 2024
на канале: Code Samples
92
2

I have JavaScript that is doing activity periodically. When the user is not looking at the site (i.e., the window or tab does not have focus), it'd be nice to not run.
Is there a way to do this using JavaScript?
My reference point: Gmail Chat plays a sound if the window you're using isn't active.
Page Visibility API: http://www.w3.org/TR/page-visibility/
MDN: https://developer.mozilla.org/en-US/d...
read notes: https://dev.opera.com/blog/page-visib...
required for IE 9 and lower: http://www.thefutureoftheweb.com/blog...


Смотрите видео javascript - Is there a way to detect if a browser window is not currently active? онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Code Samples 07 Апрель 2024, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 92 раз и оно понравилось 2 людям.