检测重点是浏览器地址栏?

问题描述:

有没有办法检测何时将焦点放在地址栏或浏览器搜索栏上?

Is there a way to detect when focus has been put onto the address-bar or the browser-search-bar?

我问,因为我试图保持专注于我的文档中的一个元素,但为该元素添加 blur()侦听器(调用 focus()在同一个元素上)在 Safari Mac中运行得很好 - 你可以'当setFocus的超时为0时(插件需要),将焦点放在地址栏上。

I ask because I am trying to keep focus on one element in my document, but adding a blur() listener to that element (which calls focus() on that same element) works too well in Safari Mac -- you can't put focus on the address-bar when you setFocus with a timeout of 0 (necessary for a plugin).

不,这是不可能的