Chrome extension: Navigate to a url when user clicks on icon
You can also navigate active tab to required url ( without opening new tab )
chrome.tabs.query( { active: true, currentWindow: true }, function( tabs ) {
chrome.tabs.update( tabs[0].id, { url: "http://stackoverflow.com//" } );
});
You can use the following code:
chrome.tabs.update({
url: "http://www.example.com/"
});
Use chrome.tabs.update
({ url: "http://www.example.com/" })
in the onClicked
listener of your browser action. When you omit the tabId
argument, the update applies to the currently selected tab.
Despite being part of the chrome.tabs
API, this does not require the tabs
permission.