How to programmatically open a chrome extension popup window from background.html

前端 未结 4 1594
忘了有多久
忘了有多久 2020-12-13 01:07

Thanks in advance!

What I want to achieve is to open the popup window when a special tag is detected on a webpage by my extension. After searching for a while it see

4条回答
  •  渐次进展
    2020-12-13 01:19

    You cannot fake click on browser action, but you can still open the popup page from the background script as usual window popup and it will work as expected. So for example the html page of your browser action is "popup.html"

    window.open("popup.html", "extension_popup", "width=300,height=400,status=no,scrollbars=yes,resizable=no");
    

    Note: you can call it only from the background script (event page). Therefore you need to register the background script in your manifest file and add an event handler, which would open the popup.You can read more about event pages here https://developer.chrome.com/extensions/event_pages

提交回复
热议问题