tabs.getCurrent()
Get a tabs.Tab
containing information about the tab that this script is running in.
Note: This function is only useful in contexts where there is a browser tab, such as an options page.
If you call it from a background script or a popup, it will return undefined
.
This is an asynchronous function that returns a Promise
.
Syntax
js
const gettingCurrent = browser.tabs.getCurrent()
Parameters
None.
Return value
Examples
Get information about the current tab:
js
function onGot(tabInfo) {
console.log(tabInfo);
}
function onError(error) {
console.log(`Error: ${error}`);
}
const gettingCurrent = browser.tabs.getCurrent();
gettingCurrent.then(onGot, onError);
Browser compatibility
Report problems with this compatibility data on GitHubdesktop | mobile | ||||||
---|---|---|---|---|---|---|---|
getCurrent |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- See implementation notes.
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.
Note:
This API is based on Chromium's chrome.tabs
API. This documentation is derived from tabs.json
in the Chromium code.