最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Check browser tabs by JavaScript? - Stack Overflow

programmeradmin0浏览0评论

Can I check if host page for a JavaScript is active by the browser's tab in IE7/FF/Opera?

Checking other tabs than the page where this JS runs would probably be a security risk though..

My other option is a method I remember by prototype to check if the mouse cursor is active, but it's not that accurate.

Can I check if host page for a JavaScript is active by the browser's tab in IE7/FF/Opera?

Checking other tabs than the page where this JS runs would probably be a security risk though..

My other option is a method I remember by prototype to check if the mouse cursor is active, but it's not that accurate.

Share Improve this question asked Feb 4, 2009 at 16:21 olemariusolemarius 1,1344 gold badges17 silver badges27 bronze badges 2
  • If it works for him, why wait? :-) – ceejayoz Commented Feb 4, 2009 at 18:04
  • mainly wait as the guy who answered provided an answer to a different question. in this case, an accept was granted for saying what was said in the question. someone else can prove that wrong later, as happened in this case. – geowa4 Commented Feb 4, 2009 at 19:05
Add a ment  | 

1 Answer 1

Reset to default 7

You can attach the onBlur and onFocus events to the window; that will tell you if you have focus or not. I have tested this and it works. You cannot check another page, but you can definitely check your own.

发布评论

评论列表(0)

  1. 暂无评论