We're looking for a user researcher to understand the needs of developers and designers. Is this you or someone you know? Check out the post: https://mzl.la/2IGzdXS

Add-ons

sidebarAction.setTitle()

Sets the sidebar's title. The title is displayed anywhere the browser lists available sidebars. For example, Firefox will show it in the "View > Sidebar" menu. It's also shown at the top o the sidebar when the sidebar is open.

You can pass a tabId in as an optional parameter. If you do this then the title is changed only for the given tab.

Types of title

Your extension should specify an title for the sidebar in the sidebar_action manifest key. This is called the "manifest title".

If you don't specify an title in the sidebar_action key, its title is the extension name. This is called the "default title".

If you set a new title using setTitle(), and include the tabId option, then the title is set only for the given tab. This title is called the "tab-specific title".

If you set a new title using setTitle(), and omit the tabId option to setTitle(), then this sets the "global title". The global title will then appear in all tabs that do not have a tab-specific title set.

Syntax

browser.sidebarAction.setTitle(
  details // object
)

Parameters

details
object. The new title and optionally the ID of the tab to target.
title
string or null. The sidebar's new title.

If title is an empty string, the title will be reset to the default title.

If title is null, and tabId was specified, and the specified tab had a tab-specific title set: then the tab-specific title is reset to the global title (if a global title is set) or the manifest title.

if title is null, and tabId was omitted, and there was a global title set, it will be reset to the manifest title.

tabIdOptional
integer. Sets the title only for the given tab. The title is reset automatically when the tab is closed.

Browser compatibility

ChromeEdgeFirefoxFirefox for AndroidOpera
Basic support No No54 No30
The title property of the details parameter can be set to null. No No59 No No
details.windowId No No61 No No

Examples

This code changes the title for the sidebar when the user clicks a browser action, but only for the current tab:

var title = "A different title";

function setTitleForTab(tab) {
  browser.sidebarAction.setTitle({title, tabId: tab.id});    
}

browser.browserAction.onClicked.addListener(setTitleForTab);

Acknowledgements

This API is based on Opera's chrome.sidebarAction API.

Document Tags and Contributors

Contributors to this page: ExE-Boss, wbamberg
Last updated by: ExE-Boss,