2009-06-15 31 views
1

我有一个Flash对象,占用了我网站上的整个浏览器。我正在尝试检测浏览器是否处于焦点状态。做这个的最好方式是什么?使用onfocus/onblur可在FireFox中使用,但不能在IE6或IE7中使用。使用全屏闪光控制检测window.onfocus?

window.onblur = function() { 
    document.title = "NOT focused"; 
} 
window.onfocus = function() { 
    document.title = "focused" 
} 

如果我删除Flash对象,它看起来像这样将在IE6/7也行,但这不是我的选择。谢谢!

回答

1

在AS3中,你可以添加事件侦听器的阶段:

stage.addEventListener(Event.DEACTIVATE, windowNotActiveCallback); 
stage.addEventListener(Event.ACTIVATE, windowActiveCallback); 
+0

这很好 - 谢谢! – Andrew 2009-06-15 06:48:51

1
if (/*@[email protected]*/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";} 
} 
+0

要在这时候仍然有一些擦枪走火和标签页的,但肯定比我有更好的! – Andrew 2009-06-15 06:49:33