Path: blob/main/files/en-us/mozilla/add-ons/webextensions/api/tabs/getcurrent/index.md
6552 views
------{{AddonSidebar()}}
Get a {{WebExtAPIRef("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 {{jsxref("Promise")}}.
Syntax
Parameters
None.
Return value
A {{jsxref("Promise")}} that will be fulfilled with a {{WebExtAPIRef('tabs.Tab')}} object containing information about the current tab. If any error occurs the promise will be rejected with an error message.
Examples
Get information about the current tab:
{{WebExtExamples}}
Browser compatibility
{{Compat}}
Note: This API is based on Chromium's
chrome.tabsAPI. This documentation is derived fromtabs.jsonin the Chromium code.