Reputation: 437
I have a chrome extension and on start, I open a new tab. This will be my "work" tab.
How to navigate to a new url in this tab? How to identify this tab and tell him to navigate to the new url?
I'm trying with this code:
chrome.tabs.query( { active: true, currentWindow: true }, function( tabs ) {
chrome.tabs.update( tabs[0].id, { url: "http://stackoverflow.com//" } );
});
but this navigates the current tab to the new url. I need to navigate in my "work" tab.
I think I will need to take an id from the tab that I created on start and use this id as a destination for the later navigates. but, how to do this?
Upvotes: 0
Views: 279
Reputation: 437
fixed.
when create the tab, use:
chrome.tabs.create({index: 0, url: 'http://stackoverflow.com'}, function() {});
for update the url in this tab:
chrome.tabs.query( { active: false, currentWindow: true }, function( tabs ) {
chrome.tabs.update( tabs[0].id, { url: "http://stackoverflow.com//" } );
});
active must be set to false.
Upvotes: 1