Chrome扩展程序:打开新标签页而不会丢失弹出式窗口 [英] Chrome Extension: Open new tab without losing popup focus

查看:110
本文介绍了Chrome扩展程序:打开新标签页而不会丢失弹出式窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Chrome扩展程序中有一个简单的研究链接列表:

I have a simple list of research links on a Chrome Extension:

<a href="http://www.example1.com" target="_blank">Research Link 1</a>
<a href="http://www.example2.com" target="_blank">Research Link 2</a>
<a href="http://www.example3.com" target="_blank">Research Link 3</a>

在任何网页上,我都可以按住Ctrl并点击全部三个链接,在后台打开新标签页。但是,Chrome扩展程序弹出窗口似乎并不是这种情况。如果您点击某个链接,该扩展程序会关闭该弹出窗口,这会阻止您随时点击多个链接。

On any webpage, I could ctrl+click all three links, opening new tabs in the background. However, this doesn't seem to be the case with a Chrome Extension Popup. If you ctrl+click on a link, the extension closes the popup, which prevents you from clicking more than one link at any time.

点击chrome.tabs.create方法,这在其他几篇文章中都有描述,但是这只是点击target =_ blank,因为它只是打开一个带有焦点的新选项卡。

I've tried an on-click chrome.tabs.create approach which is described in several other posts, but that seems similar to just clicking target="_blank" as it just opens a new tab with focus.

chrome.tabs.create({url: 'http://www.google.com'});

有没有办法打开一个没有焦点的新标签(ctrl + click),同时仍然允许扩展弹出窗口在当前选项卡中保持可见状态,以便用户可以单击第二,第三或第四个链接?这样用户不必重新运行扩展多次,这需要时间,因为它必须重新进行数据验证和查询。

Is there any way to open a new tab without focus (ctrl+click), while still allowing the extension popup to remain visible in the current tab so that the user can click a second, third, or fourth link? That way the user doesn't have to rerun the extension several times, which takes time as it has to authenticate and query for the data all over again.

推荐答案

是的,有 创建

chrome.tabs.create({url: 'http://www.google.com', active: false});

我正如您所描述的那样在我的一个扩展中使用它。

I'm using it in one of my extensions exactly as you described.

这篇关于Chrome扩展程序:打开新标签页而不会丢失弹出式窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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