活动标签旁边的打开标签

约翰·瑟威尔

对于我的Chrome扩展程序,我需要在“活动/当前”标签旁边打开一个新标签。但是tab.create方法总是将选项卡附加在选项卡列表的末尾。

Firefox具有relatedToCurrent设置标签位置的属性。

在活动标签旁边打开标签是否有与Chrome等效的标签?

田中阳一郎

您可以使用“ index”属性在调用chrome.tabs.create()函数时指定位置。如果要在当前选项卡旁边打开一个新选项卡:

chrome.tabs.query({
    active: true, currentWindow: true
  }, tabs => {
    let index = tabs[0].index;
    chrome.tabs.create({
      ...,
      index: index + 1,
      ...
    }, tab => {
      ...
    });
  }
);

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章