Chrome扩展程序;在新选项卡中打开popup.html中的链接 [英] Chrome extension; open a link from popup.html in a new tab
问题描述
我正在做一个Chrome扩展程序,并且在这篇文章中得到了帮助这里
一>。现在我的问题是如何打开一个新的Chrome浏览器标签页,其链接点击 popup.html
。我试图像在其他类似问题(如设置< a>
的属性目标
到 _blank
,但唯一的结果是chrome确实打开了一个新选项卡,但在新选项卡中是我的popup.html。
任何想法如何解决这个问题?
谢谢。
您应该使用 chrome.tabs 模块手动打开新选项卡中的所需链接。尝试在popup.html中使用这个jQuery代码片段:
$(document).ready(function(){
$('body')。on('click','a',function(){
chrome.tabs.create({url:$(this).attr('href')});
返回false;
});
});
I'm doing a Chrome extension and I got helped in this post here.
My problem now is how to open a new tab of chrome that has as URL the link I clicked in the popup.html
. I tried to do like someone suggested in their answers in other similar question like setting <a>
's attribute target
to _blank
but the only result is that chrome does open a new tab but in the new tab is my popup.html.
Any idea how to solve this?
Thanks.
You should use chrome.tabs module to manually open the desired link in a new tab. Try using this jQuery snippet in your popup.html:
$(document).ready(function(){
$('body').on('click', 'a', function(){
chrome.tabs.create({url: $(this).attr('href')});
return false;
});
});
这篇关于Chrome扩展程序;在新选项卡中打开popup.html中的链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!