Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome Extension: Open tab without popup

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.

like image 570
usertest Avatar asked Apr 12 '11 21:04

usertest


1 Answers

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) {

    });
});
like image 168
serg Avatar answered Sep 30 '22 06:09

serg