[英]JavaScript/Chrome Extension Opening a New Tab In The Second Slot
I would like to make a function to open a new tab in the second slot of google chrome for instance.例如,我想做一个 function 在谷歌浏览器的第二个插槽中打开一个新标签。 I have been using the manual so I am unsure what the exact mistake is.我一直在使用手册,所以我不确定确切的错误是什么。 For instance, if there are five tabs open, I want the new tab to open between the original first and second ones.例如,如果打开了五个选项卡,我希望新选项卡在原来的第一个和第二个选项卡之间打开。
var newURL = "http://google.com/";
chrome.tabs.create({url: newURL, tabId: 2});
You will need to pass the index
in your options argument in order to create a new tab at a specific position.您需要在选项参数中传递index
,以便在特定 position 处创建新选项卡。
Example:例子:
var newURL = "http://google.com/";
// Starts at 0. Therefore the new tab will be created in the second position
chrome.tabs.create({url: newURL, index: 1});
Reference: https://developer.chrome.com/docs/extensions/reference/tabs/#method-create参考: https://developer.chrome.com/docs/extensions/reference/tabs/#method-create
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.