Chrome Extension: Open tab without popup
12,082
Popup is optional. Just remove default_popup
property from your manifest and then you can listen to icon click events in a background page or event page:
chrome.browserAction.onClicked.addListener(function(tab) {
chrome.tabs.create({
'url': chrome.extension.getURL('page.html')
}, function(tab) {
});
});
Related videos on Youtube
Author by
usertest
Updated on August 09, 2020Comments
-
usertest over 3 years
I've used the following code in my popup.html file:
<script type="text/javascript" charset="utf-8"> chrome.tabs.create({'url': chrome.extension.getURL('page.html')}, function(tab) { }); </script>
When I click the extension icon a new page does open, but so does an empty browser popup near the button. How do I open the tab without the empty popup appearing?
Thanks.
-
Mihai Parparita about 13 yearsAlternatively, if you don't want to use a background page just to add an onclick handler, you can call window.close() in your popup to have it close as soon as it opens.