tabs

Interact with the browser's tab system. You can use this API to get a list of opened tabs and to create, modify, and rearrange tabs in the browser.

You can use most of this API without any special permission. However, to access Tab.url, Tab.title, and Tab.faviconUrl, you need to have the "tabs" permission. In Firefox this also means you need "tabs" to query (en-US) by URL.

Types

tabs.MutedInfoReason (en-US)
An event that caused a muted state change.
tabs.MutedInfo (en-US)
Tab muted state and the reason for the last state change.
tabs.Tab (en-US)
Contains various properties of a single tab.
tabs.ZoomSettingsMode (en-US)
Defines how zoom changes are handled, i.e. which entity is responsible for the actual scaling of the page; defaults to automatic.
tabs.ZoomSettingsScope (en-US)
Defines whether zoom changes will persist for the page's origin, or only take effect in this tab; defaults to per-origin when in automatic mode, and per-tab otherwise.
tabs.ZoomSettings (en-US)
Defines how zoom changes in a tab are handled and at what scope.
tabs.TabStatus (en-US)
Whether the tabs have completed loading.
tabs.WindowType (en-US)
The type of window.

Properties

tabs.TAB_ID_NONE (en-US)
An ID which represents the absence of a browser tab.

Functions

tabs.get()
Retrieves details about the specified tab.
tabs.getCurrent() (en-US)
Gets the tab that this script call is being made from. May be undefined if called from a non-tab context (for example: a background page or popup view).
tabs.connect() (en-US)
Connects to the content script(s) in the specified tab. The runtime.onConnect (en-US) event is fired in each content script running in the specified tab for the current extension. For more details, see content script messaging.
tabs.sendRequest() (en-US)
Sends a single request to the content script(s) in the specified tab, with an optional callback to run when a response is sent back. The extension.onRequest (en-US) event is fired in each content script running in the specified tab for the current extension.
tabs.sendMessage() (en-US)
Sends a single message to the content script(s) in the specified tab, with an optional callback to run when a response is sent back. The runtime.onMessage (en-US) event is fired in each content script running in the specified tab for the current extension.
tabs.getSelected() (en-US)
Gets the tab that is selected in the specified window.
tabs.getAllInWindow() (en-US)
Gets details about all tabs in the specified window.
tabs.create() (en-US)
Creates a new tab.
tabs.duplicate() (en-US)
Duplicates a tab.
tabs.query() (en-US)
Gets all tabs that have the specified properties, or all tabs if no properties are specified.
tabs.highlight() (en-US)
Highlights the given tabs.
tabs.update() (en-US)
Modifies the properties of a tab. Properties that are not specified in updateProperties are not modified.
tabs.move() (en-US)
Moves one or more tabs to a new position within its window, or to a new window. Note that tabs can only be moved to and from normal (window.type === "normal") windows.
tabs.reload() (en-US)
Reload a tab.
tabs.remove() (en-US)
Closes one or more tabs.
tabs.detectLanguage() (en-US)
Detects the primary language of the content in a tab.
tabs.captureVisibleTab() (en-US)
Captures the visible area of the currently active tab in the specified window. You must have <all_urls> permission to use this method.
tabs.executeScript() (en-US)
Injects JavaScript code into a page. For details, see the programmatic injection section of the content scripts doc.
tabs.insertCSS() (en-US)
Injects CSS into a page. For details, see the programmatic injection section of the content scripts doc.
tabs.setZoom() (en-US)
Zooms a specified tab.
tabs.getZoom() (en-US)
Gets the current zoom factor of a specified tab.
tabs.setZoomSettings() (en-US)
Sets the zoom settings for a specified tab, which define how zoom changes are handled. These settings are reset to defaults upon navigating the tab.
tabs.getZoomSettings() (en-US)
Gets the current zoom settings of a specified tab.

Events

tabs.onCreated (en-US)
Fired when a tab is created. Note that the tab's URL may not be set at the time this event fired, but you can listen to onUpdated events to be notified when a URL is set.
tabs.onUpdated (en-US)
Fired when a tab is updated.
tabs.onMoved (en-US)
Fired when a tab is moved within a window. Only one move event is fired, representing the tab the user directly moved. Move events are not fired for the other tabs that must move in response. This event is not fired when a tab is moved between windows. For that, see tabs.onDetached (en-US).
tabs.onSelectionChanged (en-US)
Fires when the selected tab in a window changes.
tabs.onActiveChanged (en-US)
Fires when the selected tab in a window changes. Note that the tab's URL may not be set at the time this event fired, but you can listen to tabs.onUpdated (en-US) events to be notified when a URL is set.
tabs.onActivated (en-US)
Fires when the active tab in a window changes. Note that the tab's URL may not be set at the time this event fired, but you can listen to onUpdated events to be notified when a URL is set.
tabs.onHighlightChanged (en-US)
Fired when the highlighted or selected tabs in a window changes.
tabs.onHighlighted (en-US)
Fired when the highlighted or selected tabs in a window changes.
tabs.onDetached (en-US)
Fired when a tab is detached from a window, for example because it is being moved between windows.
tabs.onAttached (en-US)
Fired when a tab is attached to a window, for example because it was moved between windows.
tabs.onRemoved (en-US)
Fired when a tab is closed.
tabs.onReplaced (en-US)
Fired when a tab is replaced with another tab due to prerendering or instant.
tabs.onZoomChange (en-US)
Fired when a tab is zoomed.

Browser compatibility

BCD tables only load in the browser

Example extensions

Acknowledgements

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