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

It is impossible to get the extension window to open without a user clicking on it… However, you can get the extension popup page to open in a new tab as follows:

1) Set your background page in your manifest file…

"background_page": "background.html",

This is where you will run the code to see whether the special tag is detected… background pages can constantly run code in the background, and it is up to you to set a repeat loop to check whether you variable condition is true every so often…

2) Enable tabs permission in your manifest file…

"permissions": [ "tabs" ],

This permission is needed for step 3 (Allows the background page to open a new tab)

3) In background page, call create and point to the extension popup url.

if(condition == true){
  chrome.tabs.create({url:"popup.html"});
}

Leave a Comment