Esta tradução está incompleta. Por favor, ajude a traduzir este artigo do Inglês.

Normalmente referido como uma ação da página, esta opção da inteface do utilizador é um botão adicionado à barra de endereço do navegador. Os utilziadores clicam no botão para interagir com a sua extensão.

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 extension's features are applicable to almost every web page.

Especificar a ação da página

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 extension, which the extension listens 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.

Exemplos

The webextensions-examples repo on GitHub, contains several examples of extensions that use page action:

  • chill-out uses a page action without a popup.

Etiquetas do documento e contribuidores

Contribuidores para esta página: mansil
Última atualização por: mansil,