使用 Chrome 和 Safari 扩展突出显示 URL 栏 [英] Highlight URL bar using Chrome and Safari extension
问题描述
是否可以使用 Google Chrome 扩展程序或 Safari 扩展程序突出显示 URL 栏(将焦点设置到地址栏)?
使用 Firefox 扩展,可以像这样突出显示 URL 栏:
var addressBar=document.getElementById('urlbar');addressBar.focus();addressBar.select();
我不确定 Chrome 和 Safari 是否有类似的功能.
预先感谢您的帮助!
Firefox,在其插件和扩展中可以访问浏览器的chrome"(页面周围的 UI 内容),这使得这成为可能,尽管我不确定你提到的api.
然而,Google Chrome 清楚地表明其暴露于浏览器的 chrome 到扩展程序,并且仅通过 browser actions
和 page actions
提供访问权限.此外,您可以使用 HTML5 Desktop Notifications
、Context Menus
和 Omnibox
来更多地利用浏览器.>
但恐怕您无法从 Chrome 明确拒绝通过 javascript 或扩展程序访问的扩展程序(或其他方式)访问地址栏.
您最多可以做的是向用户指出按 Ctrl+L
将使他们进入浏览器的地址栏,或者如果您想重定向用户,您可以使用 window.location.href = 'https://stackoverflow.com'
.
Is it possible to highlight the URL bar (set focus to the location bar) using Google Chrome extensions or Safari extensions?
Using Firefox extensions, one can highlight the URL bar like this:
var addressBar=document.getElementById('urlbar');
addressBar.focus();
addressBar.select();
I'm not sure if there's similar functionality in Chrome and Safari.
Thanks in advance for your help!
Firefox, in its plugins and extensions gives access to browser's "chrome" (the UI stuff around the page) which makes this possible, although I am not sure of the api that you have mentioned.
Google Chrome, however, is clear about its exposure to browser's chrome to the extension and gives access only through browser actions
and page actions
. Moreover you can use HTML5 Desktop Notifications
, Context Menus
and Omnibox
to get more out of the browser.
But I am afraid you cannot access the address bar from extensions (or otherwise) which Chrome explicitly denies access to via javascript or Extensions.
At most what you can do is to point it out to user that pressing Ctrl+L
will get them to browser's address bar or if you want to redirect the user you can use window.location.href = 'https://stackoverflow.com'
.
这篇关于使用 Chrome 和 Safari 扩展突出显示 URL 栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!