I’m developing a chrome extension and I want to open a new tab, but after the current tab that user is on. This is what I’ve tried to do:
function clickEvent(info, tab) {
update();
var url= "http://google.com";
var id = tab.id+1;
chrome.tabs.create({'url': url, 'index': id});
}
but the created tab opens at the end of tabs queue in chrome tab bar. After removing 'index': id from chrome.tabs.create, the result is same. I don’t know how can I resolve the problem. Can anybody help me?
The tab is appended at the end because you’re using the wrong argument (
idshould beindex). The tabidis a positive integer which uniquely identifies tabs within a session. Consequently, the value ofidis always higher than the number of tabs.The position of the tab can be read from the
indexproperty. So, replaceidwithindex: