使用Chrome和Safari扩展程序突出显示URL栏 [英] Highlight URL bar using Chrome and Safari extension

查看:141
本文介绍了使用Chrome和Safari扩展程序突出显示URL栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用Google Chrome浏览器扩展程序或Safari扩展程序突出显示网址栏(将焦点设置到位置栏)?



使用Firefox扩展程序,可以突出显示这样的URL栏:

  var addressBar = document.getElementById('urlbar'); 
addressBar.focus();
addressBar.select();

我不确定Chrome和Safari中是否有类似的功能。



在此先感谢您的帮助!解决方案

浏览器的chrome(页面周围的用户界面东西),这使得这成为可能,但我不确定你提到的api。



然而,是明确暴露于浏览器的扩展到扩展,并通过浏览器操作页面操作提供访问权限。此外,您可以使用HTML5 桌面通知上下文菜单 Omnibox 以更多地使用浏览器。



但是,我担心您无法从扩展程序(或其他方式)访问Chrome的地址栏拒绝通过javascript或Extensions进行访问。



至多你可以做的是指出用户按下 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屋!

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