Javascript- document/window has focus? [duplicate]
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;
}
精彩评论