最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Detect focus on browser address bar? - Stack Overflow

programmeradmin1浏览0评论

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

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).

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

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).

Share Improve this question edited Apr 5, 2020 at 21:40 Brian Tompsett - 汤莱恩 5,88372 gold badges61 silver badges133 bronze badges asked Mar 23, 2010 at 15:11 jedierikbjedierikb 13.1k23 gold badges101 silver badges170 bronze badges
Add a comment  | 

3 Answers 3

Reset to default 17

No, it is not possible

You can only work with the DOM.

If you want to access address bar, you need a control running in the browser or your own toolbar.

why not check when the desired element has lost focus? and work your way from there? and what i meant was using the .focusout() event, instead of .blur() since it behaves different.

http://api.jquery.com/focusout/

发布评论

评论列表(0)

  1. 暂无评论