Answer the question
In order to leave comments, you need to log in
How does JavaScript know that the page is open and not collapsed?
There are sites that understand that the page is open and look at it.
How to implement this in JavaScript?
Thanks
Answer the question
In order to leave comments, you need to log in
// Проверка активна ли в настоящий момент вкладка браузера
var isActive = true;
function onBlur() { // окно теряет фокус
isActive = false;
05
// что-то делаем
}
function onFocus() {// окно получает фокус
isActive = true;
// что-то делаем
}
if (/*@[email protected]*/false) { // для Internet Explorer
document.onfocusin = onFocus;
document.onfocusout = onBlur;
} else {
window.onfocus = onFocus;
window.onblur = onBlur;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question