javascript test if element has focus
var myElement = document.getElementById('myID');
if(myElement === document.activeElement){
//myElement Has Focus
}
javascript test if element has focus
var myElement = document.getElementById('myID');
if(myElement === document.activeElement){
//myElement Has Focus
}
javascript if browser out of focus
var hidden, visibilityChange;
if (typeof document.hidden !== "undefined") { // Opera 12.10 and Firefox 18 and later support
hidden = "hidden";
visibilityChange = "visibilitychange";
} else if (typeof document.msHidden !== "undefined") {
hidden = "msHidden";
visibilityChange = "msvisibilitychange";
} else if (typeof document.webkitHidden !== "undefined") {
hidden = "webkitHidden";
visibilityChange = "webkitvisibilitychange";
}
function handleVisibilityChange() {
if (document[hidden]) {
// Do here something if page is hidden (not in focus)
} else {
// Do here something if page is in focus
}
}
if (typeof document.addEventListener === "undefined" || hidden === undefined) { // Skip if the browser doesn't support addEventListener or the Page Visibility API
} else {
document.addEventListener(visibilityChange, handleVisibilityChange, false); // Handle page visibility change
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us