docs.rodeo

MDN Web Docs mirror

browserAction

{{AddonSidebar}} 

Read and modify attributes of and listen to clicks on the browser toolbar button defined with the browser_action manifest key.

A browser action is a button in the browser’s toolbar.

You can associate a popup with the button. Like a web page, the popup is specified using HTML, CSS, and JavaScript. JavaScript running in the popup gets access to the same WebExtension APIs as your background scripts, but its global context is the popup, not the current page displayed in the browser. To affect web pages, you need to communicate with them via messages.

If you specify a popup, it is shown — and the content loaded — when the user clicks the icon. If you do not specify a popup, an event is dispatched to your extension when the user clicks the icon.

The button also has a context menu, and you can add items to this menu with the {{WebExtAPIRef("menus")}}  API using the browser_action {{WebExtAPIRef("menus.ContextType")}} .

With the browserAction API, you can:

Types

Functions

Events

Browser compatibility

{{Compat}} 

{{WebExtExamples("h2")}} 

[!NOTE] This API is based on Chromium’s chrome.browserAction API. This documentation is derived from browser_action.json in the Chromium code.

In this article

View on MDN