如何捕获整个浏览器窗口的模糊和焦点? [英] How can I capture the blur and focus of the entire browser window?

查看:118
本文介绍了如何捕获整个浏览器窗口的模糊和焦点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想捕捉实际浏览器窗口的模糊和焦点 - 意味着焦点更改为子帧不感兴趣。

I would like to capture the blur and focus of the actual browser window - meaning that change of focus to child frames is not of interest.

目前我一直在使用
$(上).focus()
$(上).blur()


$(窗口).focus()
$(窗口).blur()

然而,当用户将焦点更改为嵌入式iframe时,这些会触发,我不这样做希望。

However, these fire when the user changes focus to embedded iframes, which I don't want.

有没有人知道如何捕获TRUE激活和停用窗口?

Does anyone know of a way to capture TRUE activation and deactivation of the window?

]

当用户从网页移动到嵌入式iframe的网页时,模糊和焦点事件会触发。
这与窗口激活事件不同,事件激活事件仅在实际的浏览器窗口(或选项卡)被带到前面或被发送(即,更改或最小化)时触发。

Blur and focus events fire when a user moves from a web-page, to the web-page of an embedded iframe. This is different from 'window activation' events, which only fire when the actual BROWSER WINDOW (or tab) is brought to the front, or sent away (i.e, tab changed, or minimized).

我对模糊不感兴趣,因为用户导航到嵌入式框架的事实对程序没有影响。但是,如果用户最小化窗口,更改选项卡或切换到另一个程序,我想知道它...

I am not interested in blur, because the fact that the user has navigated to an embedded frame is of no consequence to the program. However, if the user minimizes the window, changes tabs, or switches to another program, I want to know about it...

推荐答案

我有这个

$(function() {

    $(window)
        .focus(function() { document.getElementById('play_banner').value = true; })
        .blur(function() { document.getElementById('play_banner').value = false; })

 })

在IE,firefox和chrome上工作正常只有当play_banner设置为true时才有效,所以当用户更改页面时它会停止工作,当他回来时它会继续从那里开始......

working fine on IE, firefox and chrome, where the banner only animate when play_banner is set to true, so it stop working when the user changes the page, and when he's back it continues from where it was...

这篇关于如何捕获整个浏览器窗口的模糊和焦点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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