Reputation: 1887
how can i get the new created tab ID after chrome.tabs.create? and what if it was more that one tab create in the same time?
thank you.
Upvotes: 9
Views: 5079
Reputation: 2905
The chrome.tabs.create
API has the callback function that returns an object
containing the new tab details
chrome.tabs.create({"url":url},function(newTab) {
console.log(newTab.id);
});
Upvotes: 9
Reputation: 1887
ok found the solution
chrome.tabs.onCreated.addListener(function(tab){
alert("new tab "+tab.id);
});
Upvotes: 5