Joined March 2018
·

jithinktom

Posted to How to tell if app/page has focus over 1 year ago

Why should we use even visibility change API? The window focus and blur event listeners works good. And even without knockout.js . Please take a look:

var checkFocus = function() {
console.log(document.hasFocus());
}
checkFocus(); // init

window.addEventListener("focus", checkFocus);
window.addEventListener("blur", checkFocus);

Achievements
1 Karma
0 Total ProTip Views