I'm trying to hide my website when it loses focus. The problem is that it loses focus when I click inside an iframe on the site. To prevent this I have the following code, and it works perfectly in Chrome and even Edge. Why is this not working in Firefox?
jQuery(window).focus(function() {
jQuery("body").show();
}).blur(function() {
if(document.activeElement != (document.getElementsByTagName("iframe")[0] || document.getElementsByTagName("embed")[0])) {
jQuery("body").hide();
}
});
jQuery(document).ready doesn't solve my problem