Suppose you have just opened Chrome. There is a “New Tab” already open. My extension has a button that when the user presses it, I create a new tab to show my contents (index.html).
Now everything works fine, but the problem is that “New Tab” is left useless. I use the following call to create a new tab:
chrome.tabs.create({
"url":"index.html"
});
update() doesn’t work (nothing happens).
chrome.tabs.update({
"url":"index.html"
});
When I check the current tab, it says “undefined”:
chrome.tabs.getCurrent(function(t){console.log(t.id)})
How can I use the current empty tab instead of creating a new one? I see some other extensions (namely Google Mail Checker) have the same issue.
Apparently, the Tabs API does not allow you to omit leading optional argunemts like, e.g., jQuery does. To change the current tab, you need to explictly include
nullas the first argument (tabId) toupdate():