function doit() { alert(3); // Statement 1 // chrome.tabs.create({url:"http://www.google.com"}); // Statement 2 // chrome.tabs.update({url:"http://en.wikipedia.org"}); alert(4); } chrome.browserAction.onClicked.addListener(doit);
When the script works as is, I get JS 3 and 4 warnings. OK.
When I comment in instruction 1 and run the script, I get a JS warning of 3, then Google opens on a new active tab, then I get a JS warning of 4. As expected.
When I comment on expression 1 and comment in statement 2, I get a JS warning of 3, and that is.
According to http://code.google.com/chrome/extensions/tabs.html#method-update , I donβt need to pass the tabId object because it "defaults to the selected tab of the current window". The url object is defined as the βURL to go through the tab,β as I noticed when I ran chrome.tabs.create in instruction 1.
Why is my chrome.tabs.update instruction not working?
source share