开发者

Javascript- document/window has focus? [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicate:

How 开发者_运维技巧do I find out which Javascript element has focus?

Is it possible to check in Javascript whether the current window has focus?


No, not really. May be you could assign handlers to the focus/blur events of the window, setting a boolean to true or false and use that to determine if it has focus or not.

Something along this line:

window.hasfocus = false;

window.onfocus = function(){
   this.hasfocus = true;
}

window.onblur = function(){
   this.hasfocus = false;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜