Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get a chrome extension to open a page, not a popup

I'm pretty new to making extensions, so I'm not sure if this is how they work. In the manifest.json, you can set the browser action to have a default popup. I have my html code and it pops up when you click the extension icon, however, I would like it to open this html in the window or a new tab, and not inside a small popup window. Any way to do this? I couldn't find a quick fix.

like image 243
12343211234 Avatar asked Mar 16 '23 14:03

12343211234


1 Answers

To open the popup.html in a new tab, you can pass in the extension url in background.js. See: https://developer.chrome.com/extensions/extension#method-getURL

Like:

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

   });
});
like image 163
Dayton Wang Avatar answered Apr 01 '23 12:04

Dayton Wang