My goal is to detect focus in and focus out events on the entire web page. Here is the code I am using:
function focus_in(){
console.log("focus");
}
function focus_out(){
console.log("blur");
}
window.addEventListener("focus", focus_in, false);
window.addEventListener("blur", focus_out, false);
It works perfectly fine on Chrome browser. However, when testing on Windows 7 with IE 11 or 10, I noticed that the focus event triggers an unwanted blur event as well.
I have attempted the following solution:
window.onfocusout = focus_out
window.onfocusin = focus_in