对于我的Chrome扩展,我需要在active/current选项卡旁边打开一个新选项卡。但是tab.create方法总是在选项卡列表的末尾追加该选项卡。
火狐具有设置选项卡位置的relatedToCurrent属性。
在active选项卡旁边打开选项卡有任何Chrome等效吗?
发布于 2016-03-04 01:22:34
您可以使用"index“属性指定在调用chrome.tabs.create()函数时的位置。如果您想在当前选项卡旁边打开一个新选项卡:
chrome.tabs.query({
active: true, currentWindow: true
}, tabs => {
let index = tabs[0].index;
chrome.tabs.create({
...,
index: index + 1,
...
}, tab => {
...
});
}
);https://stackoverflow.com/questions/35780106
复制相似问题