开发者

How can I check whether a browser window/tab is focused?

I know the window.blur / focus solution.

Can't use it.

It is a small widget. It lives in an iframe, and because of this, this method is not working. And since the iframe is loaded from a different domain there is no way to reach the top level window object.

Here: http://www.actionscript.org/forums/showpost.php3?p=1078962&postcount=5

"With the recent new 10.3 player this should be much easier, since there are new events for this specific situation."

So, using a simple flash object, and maybe js callbacks this might be the solution, but w开发者_运维问答hat are theese events? Does anyone know?


This doesn't really answer your question, but you might want to take a look at the Page Visibility API. (I've also built a simple demo.)

What are you trying to do when the window/tab gets focus?

Can window.postMessage help you? (See this post for discussion of backwards compatible alternatives.)


This probably isn’t helpful in general, but new versions of Firefox and Chrome reduce the setInterval timing to a maximum of one poll per second in background tabs. You could probably rig up an increment checker that compares a variable incrementing in a setInterval loop against a start Date / end Date value.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜