1
可能重复:
How do I find out which Javascript element has focus?Javascript-文档/窗口有焦点?
是否可以检查在Javascript当前窗口是否具有焦点?
可能重复:
How do I find out which Javascript element has focus?Javascript-文档/窗口有焦点?
是否可以检查在Javascript当前窗口是否具有焦点?
不,不是真的。也许你可以为窗口的焦点/模糊事件分配处理程序,设置一个布尔值为true或false,并用它来确定它是否有焦点。
window.hasfocus = false;
window.onfocus = function(){
this.hasfocus = true;
}
window.onblur = function(){
this.hasfocus = false;
}
伟大的想法:沿着这条线
东西,但是我会将标准值设置为“true”,因为当您加载代码时,窗口可能已经具有焦点。 – Thomas 2013-05-08 12:13:20
见http://stackoverflow.com/questions/497094/how-do-i-find-out-which-javascript-element-has-focus – chelmertz 2011-03-19 18:03:01