确定Webkit中的窗口是否处于活动状态 [英] Determine if window is active in webkit

查看:95
本文介绍了确定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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆