Hi all,
Is there a way that when i click on my browser, and give it focus, to run a method once? And then when the browser loses focus and then get focus back to again run that method only once, again.
Thanks,
rod.
Hi all,
Is there a way that when i click on my browser, and give it focus, to run a method once? And then when the browser loses focus and then get focus back to again run that method only once, again.
Thanks,
rod.
You can attach focus and blur event handlers on the window object to track if the window gets or loses focus (see http://jsfiddle.net/whQFz/ for a trivial example). window applies to the current browser context (so that could be a window, a tab, a frame, etc.).
Note however that the focus event will fire every time the window gets focus and the blur event will focus every time it loses focus. An example of something that takes focus away from the window is an alert (so if you try to alert in an onfocus event handler you'll get an infinite loop of alerts!)