admin管理员组

文章数量:1423068

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.

本文标签: Check browser tabs by JavaScriptStack Overflow