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 by URL.

Types

tabs.MutedInfoReason
An event that caused a muted state change.
tabs.MutedInfo
Tab muted state and the reason for the last state change.
tabs.Tab
Contains various properties of a single tab.
tabs.ZoomSettingsMode
Defines how zoom changes are handled, i.e. which entity is responsible for the actual scaling of the page; defaults to automatic.
tabs.ZoomSettingsScope
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
Defines how zoom changes in a tab are handled and at what scope.
tabs.TabStatus
Whether the tabs have completed loading.
tabs.WindowType
The type of window.

Properties

tabs.TAB_ID_NONE
An ID which represents the absence of a browser tab.

Functions

tabs.get()
Retrieves details about the specified tab.
tabs.getCurrent()
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()
Connects to the content script(s) in the specified tab. The runtime.onConnect 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()
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 event is fired in each content script running in the specified tab for the current extension.
tabs.sendMessage()
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 event is fired in each content script running in the specified tab for the current extension.
tabs.getSelected()
Gets the tab that is selected in the specified window.
tabs.getAllInWindow()
Gets details about all tabs in the specified window.
tabs.create()
Creates a new tab.
tabs.duplicate()
Duplicates a tab.
tabs.query()
Gets all tabs that have the specified properties, or all tabs if no properties are specified.
tabs.highlight()
Highlights the given tabs.
tabs.update()
Modifies the properties of a tab. Properties that are not specified in updateProperties are not modified.
tabs.move()
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()
Reload a tab.
tabs.remove()
Closes one or more tabs.
tabs.detectLanguage()
Detects the primary language of the content in a tab.
tabs.captureVisibleTab()
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()
Injects JavaScript code into a page. For details, see the programmatic injection section of the content scripts doc.
tabs.insertCSS()
Injects CSS into a page. For details, see the programmatic injection section of the content scripts doc.
tabs.setZoom()
Zooms a specified tab.
tabs.getZoom()
Gets the current zoom factor of a specified tab.
tabs.setZoomSettings()
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()
Gets the current zoom settings of a specified tab.

Events

tabs.onCreated
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
Fired when a tab is updated.
tabs.onMoved
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.
tabs.onSelectionChanged
Fires when the selected tab in a window changes.
tabs.onActiveChanged
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 events to be notified when a URL is set.
tabs.onActivated
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
Fired when the highlighted or selected tabs in a window changes.
tabs.onHighlighted
Fired when the highlighted or selected tabs in a window changes.
tabs.onDetached
Fired when a tab is detached from a window, for example because it is being moved between windows.
tabs.onAttached
Fired when a tab is attached to a window, for example because it was moved between windows.
tabs.onRemoved
Fired when a tab is closed.
tabs.onReplaced
Fired when a tab is replaced with another tab due to prerendering or instant.
tabs.onZoomChange
Fired when a tab is zoomed.

Browser compatibility

BCD tables only load in the browser

Example extensions