Reputation: 351
I have a flash object that takes up the whole browser on my website. I am trying to detect if the browser is in focus or not. What is the best way to do this? Using onfocus / onblur works in FireFox, but not in IE6 or IE7.
window.onblur = function() {
document.title = "NOT focused";
}
window.onfocus = function() {
document.title = "focused"
}
If I remove the flash object, it looks like this will work in IE6/7 also, but that is not an option for me. Thanks!
Upvotes: 1
Views: 947
Reputation: 2077
In AS3 you can add an event listener to the stage:
stage.addEventListener(Event.DEACTIVATE, windowNotActiveCallback);
stage.addEventListener(Event.ACTIVATE, windowActiveCallback);
Upvotes: 1
Reputation: 50298
if (/*@cc_on!@*/false) { // check for Internet Explorer
document.onfocusin = function(){document.title = "focused";}
document.onfocusout = function(){document.title = "NOT focused";}
} else {
window.onfocus = function(){document.title = "focused";}
window.onblur = function(){document.title = "NOT focused";}
}
Upvotes: 1