对于我的Chrome扩展程序,我需要在活动/当前标签旁边打开一个新标签页。但tab.create
方法始终在选项卡列表的末尾附加选项卡。
Firefox具有relatedToCurrent
属性来设置标签位置。
是否有任何Chrome等效项可用于打开活动标签旁边的标签?
答案 0 :(得分:7)
您可以使用“index”属性指定调用chrome.tabs.create()函数的位置。如果要打开当前选项卡旁边的新选项卡:
chrome.tabs.query({
active: true, currentWindow: true
}, tabs => {
let index = tabs[0].index;
chrome.tabs.create({
...,
index: index + 1,
...
}, tab => {
...
});
}
);