Google Chrome扩展程序-当在当前标签页中搜索某个网址时,打开指向该网址的新标签页吗? [英] Google Chrome extension - to open new tab directed to url when a certain url is searched in current tab?
问题描述
我(今天开始)对编写chrome扩展程序非常陌生,但明天需要写一个非常简单"的扩展程序...
I am very new (started today) to writing chrome extensions but need to write a 'fairly simple' one for tomorrow...
尽管如此,我真的很努力使自己陷入困境!
I am really struggling to get my head round it though!
我需要编写一个扩展名,当在当前URL中搜索某个URL时,将打开一个指向预定义URL的新选项卡或窗口(以哪个更简单!).
I need to write an extension that opens a new tab or window (whichever is easier!) directed at a predefined url is opened when a certain URL is searched in the current.
例如,如果用户输入www.facebook.com,我试图获取扩展名,然后使用www.google.com来打开新的标签/窗口.
An example of this would be if the user typed in www.facebook.com I am trying to get the extension to then open a new tab/window with www.google.com in.
任何帮助将不胜感激! 谢谢 会
Any help would be much appreciated! Thanks Will
推荐答案
在扩展名的html中,您可以为操作按钮指定锚标记,该标记会打开一个新的标签页
In your html of the extension you can specify an anchor tag for the action button which opens a new tab like this
<a href="some url" target="_newtab">content of the anchor</a>
或者,如果您要通过编程方式进行操作,则可以
or if you want to do it programmatically you can
window.open('http://google.com','_newtab');
这篇关于Google Chrome扩展程序-当在当前标签页中搜索某个网址时,打开指向该网址的新标签页吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!