确定Webkit中的窗口是否处于活动状态 [英] Determine if window is active in webkit
问题描述
是否存在一些CSS选择器或类似的选择器,可让您将不同的样式应用于Webkit中非活动页面/窗口中的元素?有滚动条: http://www.webkit.org/blog/363/styling -scrollbars/ 我正在使用它来使Titanium桌面应用程序在Mac OS X上看起来更加原生. 谢谢!
Is there some css selector or something of the like that allows you to apply different styles to elements in an inactive page/window in webkit? There is for scrollbars: http://www.webkit.org/blog/363/styling-scrollbars/ I'm using this to make a Titanium desktop application feel more native on Mac OS X. Thanks!
推荐答案
请参阅: http://www.thefutureoftheweb.com/blog/detect-browser-window-focus
这些事件在每个专业中都有效 浏览器(Firefox,Internet Explorer 6/7,Safari&歌剧).
These events work in every major browser (Firefox, Internet Explorer 6/7, Safari & Opera).
演示: http://www.thefutureoftheweb .com/demo/2007-05-16-detect-browser-window-focus/
function onBlur() {
document.body.className = 'blurred';
};
function onFocus(){
document.body.className = 'focused';
};
if (/*@cc_on!@*/false) { // check for Internet Explorer
document.onfocusin = onFocus;
document.onfocusout = onBlur;
} else {
window.onfocus = onFocus;
window.onblur = onBlur;
}
这篇关于确定Webkit中的窗口是否处于活动状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!