Google chrome extension issue: popup.html interferes with script execution in background.html

后端 未结 1 784
天命终不由人
天命终不由人 2021-01-16 13:03

I am learning how to extend Google chrome and I have run into the following problem:

I have the following manifest file:

{
    \"name\": \"My First E         


        
1条回答
  •  别那么骄傲
    2021-01-16 13:54

    As it says in the docs:

    onClicked event will not fire if the browser action has a popup.

    So if you assign any html file to your popup "popup": "popup.html" (rather than just a button without body), onClicked event isn't fired.

    You can just put your code right into popup.html (it has same privileges as a background page) if you want something to be executed each time it is opened:

    chrome.tabs.executeScript(null, {code:"alert(\"hi from background CODE\");"});
    

    0 讨论(0)
提交回复
热议问题