Skip to content Skip to sidebar Skip to footer

Setting Window.location.href Of The Current Tab In A Browser_action Chrome Extension

I'm trying to navigate the current tab to a URL in a browser_action Chrome extension, in response to a keyword that a user has entered. What's the best way to do this? First I trie

Solution 1:

There's no need for content scripts or host permissions. Just use chrome.tabs.update (the tabs permission is not needed):

chrome.browserAction.onClicked.addListener(function(tab) {
    chrome.tabs.update(tab.id, {
        url: url
    });
});

Post a Comment for "Setting Window.location.href Of The Current Tab In A Browser_action Chrome Extension"