sidebarAction.getTitle()
Gets the sidebar's title.
Just as you can set the title on a per-tab basis using sidebarAction.setTitle()
, so you can retrieve a tab-specific title by passing the tab's ID into this function.
This is an asynchronous function that returns a Promise
.
Syntax
var gettingTitle = browser.sidebarAction.getTitle(
details // object
)
Parameters
details
object
. An object with the following properties:-
tabId
Optionalinteger
. Get the title for the sidebar specific to the given tab.windowId
Optionalinteger
. Get the title for the sidebar specific to the given window.
- If
windowId
andtabId
are both supplied, the function fails and the promise it returns is rejected. - If
windowId
andtabId
are both omitted, the global title is returned.
Return value
A Promise
that will be fulfilled with a string containing the sidebar's title.
Browser compatibility
Report problems with this compatibility data on GitHubwebextensions-desktop | webextensions-mobile | |||||
---|---|---|---|---|---|---|
getTitle | ChromeNo supportNo | EdgeNo supportNo | FirefoxFull support54 | OperaFull support30 | SafariNo supportNo | Firefox for AndroidNo supportNo |
Legend
- Full support
- Full support
- No support
- No support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Examples
This code switches the title between "this" and "that" each time the user clicks the browser action
function toggleTitle(title) {
if (title == "this") {
browser.sidebarAction.setTitle({title: "that"});
} else {
browser.sidebarAction.setTitle({title: "this"});
}
}
browser.browserAction.onClicked.addListener(() => {
var gettingTitle = browser.sidebarAction.getTitle({});
gettingTitle.then(toggleTitle);
});
Acknowledgements
This API is based on Opera's chrome.sidebarAction
API.
Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.