我试图在失去焦点时隐藏我的网站。 问题是,当我点击网站上的iframe时,它失去了焦点。为了防止出现这种情况,我使用了下面的代码,它在Chrome甚至Edge中都能很好地工作。为什么这不适用于Firefox?jQuery .blur在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的(文件)。就绪并没有解决我的问题
而不是activeElement你可以尝试使用.target – Troyer