pageAction.setIcon()

Sets the icon for the page action. The icon can be specified either as the path to an image file or as the pixel data from a canvas element, or as dictionary of either one of those.

Syntax

browser.pageAction.setIcon(
  details,         // object
  function() {...} // optional function
)

Parameters

details
object. The details object has the following properties:
tabId
integer. The ID of the tab whose icon you want to set.
imageDataOptional
pageAction.ImageDataType or object. Either an ImageData object or a dictionary. If the icon is specified as a dictionary, each entry represents an icon in a particular size. The key is the size of the icon, and the value is an ImageData object of that size. For example:
{
  19: image_data_19,
  38: image_data_38
}
The image used is chosen depending on the screen's pixel density. "19" is used in normal-density screens, and "38" is used in high-density screens.
pathOptional
string or object. Either a relative image path or a dictionary {size -> relative image path} pointing to icon to be set. If the icon is specified as a dictionary, each entry represents an icon in a particular size. The key is the size of the icon, and the value is a path to an image file of that size. For example:
{
  19: "path/to/image_19.png",
  38: "path/to/image_38.png"
}
The image used is chosen depending on the screen's pixel density. "19" is used in normal-density screens, and "38" is used in high-density screens.
callbackOptional
function. Called with no arguments, once the icon has been set.

Browser compatibility

Feature Chrome Edge Firefox (Gecko) Opera
Basic support (Yes) ? 45.0 (45.0) 33
Feature Edge Firefox OS Firefox Mobile (Gecko)
Basic support No support No support No support

Examples

Acknowledgements

This API is based on Chromium's chrome.pageAction API. This documentation is derived from page_action.json in the Chromium code.

Document Tags and Contributors

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