Address bar button

Commonly referred to as a page action, this user interface option is a button added to the browser address bar. Users click the button to interact with your add-on.

Use this button when a feature is only relevant for some web pages. By default, the address bar button is hidden in all browser tabs, and you call pageAction.show() and pageAction.hide() to show or hide it in specific tabs.

Compare to the toolbar button, which offers similar behavior but is used in situations where the add-on's features are applicable to almost every web page.

Specifying the page action

You define the page action's properties using the page_action key in manifest.json:

"page_action": {
  "browser_style": true,
  "default_icon": {
    "19": "button/geo-19.png",
    "38": "button/geo-38.png"
  },
  "default_title": "Whereami?",
}

The only mandatory key is default_icon.

There are two ways to specify a page action: with or without a popup. If you don't specify a popup, when the user clicks the button an event is dispatched to the add-on, which the add-on listen for using pageAction.onClicked:

browser.pageAction.onClicked.addListener(handleClick);

If you specify a popup, the click event is not dispatched: instead, the popup is shown when the user clicks the button. The user is able to interact with the popup and it closes automatically when the user clicks outside it. See the Popup article for more details on creating and managing popups.

Note that your extension can have one page action only.

You can change any of the page action properties programmatically using the pageAction API.

Examples

The chill-out example WebExtension, from the webextensions-examples repo on GitHub, uses a page action.

Document Tags and Contributors

 Contributors to this page: rebloor, wbamberg
 Last updated by: rebloor,