I made a browser action, but I just tried testing a page action. The button is put in the same place, but the page action button can't be clicked (the icon is greyed-out). I thought page action buttons were located on the address bar, not in the toolbar. Why is it located in the same place?
My browser action button:
My page action button:
A browser action is a button that your extension adds to the browser's toolbar. The button has an icon, and may optionally have a popup whose content is specified using HTML, CSS, and JavaScript.
A page action is a clickable icon inside the browser's address bar. You can listen for clicks on the icon, or specify a popup that will open when the icon is clicked. If you specify a popup, you can define its contents and behavior using HTML, CSS, and JavaScript—just like a normal web page.
browserAction. Use browser actions to put icons in the main Google Chrome toolbar, to the right of the address bar. In addition to its icon, a browser action can have a tooltip, a badge, and a popup.
Chrome's browser action button page says (some emphasis mine): Use browser actions to put icons in the main Google Chrome toolbar, to the right of the address bar. In addition to its icon, a browser action can also have a tooltip, a badge, and a popup. Do use browser actions for features that make sense on most pages.
Commonly referred to as a page action button, this user interface option is a button added to the browser address bar. Users click the button to interact with extensions. The address bar button (or page action) is similar to the toolbar button (or browser action).
The browser action is displayed outside the address bar, in the browser toolbar. The page action is hidden by default (although this default can be changed via the show_matches and hide_matches manifest key properties), and you call pageAction.show () and pageAction.hide () to show or hide it in specific tabs.
Like browser actions, page actions can have an icon, a tooltip, and popup; they can't have badges, however. In addition, page actions can be grayed out. You can find information about icons, tooltips, and popups by reading about the browser action UI.
Both Browser Action and Page Action buttons are located "to the right of the address bar", as described in the Extension API documentation. The two types of buttons have a lot of similarities. Which to use depends largely on if your extension is intended to be usable most of the time, or just on a small subset of pages.
Browser Action buttons are intended to be used when your extension can be used most of the time, or on most pages. They also allow you to provide some immediately visible status information to the user by having a badge containing a couple/few characters over the icon and changing the color of the background used for that badge.
Page Action buttons are intended for use when your extension is often/usually not available for use. For instance, if it's only usable on a few domains or URLs.
Browser action buttons should be used when your button is valid for use most of the time, either on most pages, or not related to/dependent upon the page that is being displayed in the active tab. By default, browser action buttons are enabled on all tabs/URLs. You have to call browserAction.disable()
to disable the button in each tab where you want it disabled (or generally disabled on all tabs). The browser action button does not change enabled/disabled state when the tab displays a different URL.
Chrome's browser action button page says (some emphasis mine):
Use browser actions to put icons in the main Google Chrome toolbar, to the right of the address bar. In addition to its icon, a browser action can also have a tooltip, a badge, and a popup.
- Do use browser actions for features that make sense on most pages.
- Don't use browser actions for features that make sense for only a few pages. Use page actions instead.
- Do use big, colorful icons that make the most of the 16x16-dip space. Browser action icons should seem a little bigger and heavier than page action icons.
- Don't attempt to mimic Google Chrome's monochrome menu icon. That doesn't work well with themes, and anyway, extensions should stand out a little.
- Do use alpha transparency to add soft edges to your icon. Because many people use themes, your icon should look nice on a variety of background colors.
- Don't constantly animate your icon. That's just annoying.
Browser actions have the following APIs:
browserAction.disable(integer tabId)
browserAction.enable(integer tabId)
browserAction.getBadgeBackgroundColor(object details, function callback)
browserAction.getBadgeText(object details, function callback)
browserAction.getPopup(object details, function callback)
browserAction.getTitle(object details, function callback)
browserAction.setBadgeBackgroundColor(object details)
browserAction.setBadgeText(object details)
browserAction.setIcon(object details, function callback)
browserAction.setPopup(object details)
browserAction.setTitle(object details)
Page action buttons should be used when the ability to use of your extension's button is dependent on the URL being shown in the active tab and when it is usually not available for use (i.e. only usable under some conditions, or on some URLs). By default, page action buttons are disabled/grayed out ("hidden") on all URLs. You have to call pageAction.show()
to enable the button for each URL/tab you want it enabled. The page action button automatically becomes disabled/hidden if the tab displays a different URL.
Chrome's page action button page says (some emphasis mine):
Use the
chrome.pageAction
API to put icons in the main Google Chrome toolbar, to the right of the address bar. Page actions represent actions that can be taken on the current page, but that aren't applicable to all pages. Page actions appear grayed out when inactive.
Like browser actions, page actions can have an icon, a tooltip, and popup; they can't have badges, however. In addition, page actions can be grayed out. You can find information about icons, tooltips, and popups by reading about the browser action UI.
You make a page action appear and be grayed out using the pageAction.show and pageAction.hide methods, respectively. By default, a page action appears grayed out. When you show it, you specify the tab in which the icon should appear. The icon remains visible until the tab is closed or starts displaying a different URL (because the user clicks a link, for example).
- Do use page actions for features that make sense for only a few pages.
- Don't use page actions for features that make sense for most pages. Use browser actions instead.
- Don't constantly animate your icon. That's just annoying.
Page actions have the following APIs:
pageAction.getPopup(object details, function callback)
pageAction.getTitle(object details, function callback)
chrome.pageAction.hide(integer tabId)
pageAction.setIcon(object details, function callback)
pageAction.setPopup(object details)
pageAction.setTitle(object details)
pageAction.show(integer tabId)
1. This API is available for both browser actions and page actions. It does basically the same thing on both.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With