Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

browserAction.setBadgeText()

Sets the badge text for the browser action. The badge is displayed on top of the icon.

Syntax

chrome.browserAction.setBadgeText(
  details // object
)

This API is also available as browser.browserAction.setBadgeText().

Parameters

details
object.
text
string. Any number of characters can be passed, but only about four can fit in the space.
tabIdOptional
integer. Set the badge text only for the given tab.

Browser compatibility

Chrome Edge Firefox Firefox for Android Opera
Basic support Yes Yes 45.0 No 33

Examples

Add a badge indicating how many times the user clicked the button:

var clicks = 0;

function increment() {
  chrome.browserAction.setBadgeText({text: (++clicks).toString()});
}

chrome.browserAction.onClicked.addListener(increment);

Acknowledgements

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

Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.

Document Tags and Contributors

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