How to modify current url location in chrome via extensions

后端 未结 3 1707
春和景丽
春和景丽 2020-12-04 11:43

I want to create an extension that redirects the user to another website if he clicks on the extension button. So far I have only seen extensions which create a new tab for

3条回答
  •  囚心锁ツ
    2020-12-04 11:47

    You can use chrome.tabs.query too

    chrome.tabs.query({currentWindow: true, active: true}, function (tab) {
          chrome.tabs.update(tab.id, {url: your_new_url});
    });
    

提交回复
热议问题