Open chrome extension in a new tab

I implemented the chrome extension. I wonder if it is possible to open popup.html in a new tab? Every click on the page and the popup disappears :( .. I wonder if I can attach it to the page or is there a way to open the extension on a new page?

+4
source share
2 answers

Yes, the popup page is just a regular extension page, you can do the following to open a new popup tab from the man page. I use this every time the user first installs the extension, I open the about page, you can do the same for the popup page.

chrome.tabs.create({url: 'popup.html'}) 

For one of my My Hangouts extensions, I have a small "open as a tab" button in the popup window, I will bind a click event for this link:

 chrome.tabs.create({url: chrome.extension.getURL('popup.html#window')}); 

The reason I passed the hash is because I wanted to add more content when the user opens it in a popup because there is more real estate with it.

Inside the popup, I use regular JavaScript to tell if I opened the tab in a new tab or on a regular page, for example:

 if (window.location.hash == '#window') { this.displayAsTab = true; } 

You can do tricks like this to improve user experience.

+5
source

here is the same problem: Chrome extension: onclick extension icon, open popup.html in a new tab

using:

 chrome.tabs.create({'url': chrome.extension.getURL('popup.html')}, function(tab) { // Tab opened. }); 

property "pinned" to attach the tab.

+1
source

Source: https://habr.com/ru/post/1399907/


All Articles