Chrome Extension: onclick extension icon, open popup.html in new tab

后端 未结 3 1433
夕颜
夕颜 2020-12-09 03:50

I have created a chrome extension and managed to open the popup.html file using window.open. however I want to open it in a new tab, I\'ve tried lo

3条回答
  •  有刺的猬
    2020-12-09 04:42

    Now you can use Event Pages to open popup.html in new tab when extension icon is clicked without creating a default_popup page.

    manifest:

    "background": {
        "scripts": ["background.js"],
        "persistent": false
    }
    

    js:

    chrome.browserAction.onClicked.addListener(function(tab) {
        chrome.tabs.create({'url': chrome.extension.getURL('popup.html'), 'selected': true});
    });
    

提交回复
热议问题