I have a web page that uses javascript counters to count user "active" time, meaning the time a user spends viewing this page (and not some other page). I do this by starting/stopping them using the document.onfocusout/onfocusin (IE) and window.onblur/onfocus (other) However, when the user clicks on a plugin inside the same page (flash, java, etc), the window loses focus and window开发者_StackOverflow.onblur is fired. Is there a way to tell that the user is still on my page?
Thanks in advance
It is a problem indeed. But you can trick your way out of it. Flash Player is able to communicate with its scripting host, in your case the JavaScript host. What you do is that when Flash Player movie receives focus, which I believe you are able to catch with ActionScript, you program it to notify it's host using the ExternalInterface
Flash Player class API, which will say, call a JavaScript function, which will start the timer again (and optionally give focus back to the page because most often stealing focus from the page is a bad idea. Flash Player steals focus by default - if you click a Flash Player movie, keyboard is not caught by JavaScript any longer, only straight by Flash Player.)
Do you understand what I'm saying?
精彩评论