chrome.tabs
- Description
Use the
chrome.tabs
API to interact with the browser's tab system. You can use this API to create, modify, and rearrange tabs in the browser.
Manifest #
You can use most chrome.tabs
methods and events without declaring any permissions in the extension's manifest file. However, if you require access to the url
, pendingUrl
, title
, or favIconUrl
properties of tabs.Tab
, you must declare the "tabs"
permission in the manifest, as shown below:
{
"name": "My extension",
...
"permissions": [
"tabs"
],
...
}
Examples #
You can find simple examples of manipulating tabs with the chrome.tabs
API in the examples/api/tabs directory. For other examples and for help in viewing the source code, see Samples.
Summary
- Types
- Properties
- Methods
chrome.tabs.captureVisibleTab(windowId?: number, options?: extensionTypes.ImageDetails, callback: function)
chrome.tabs.connect(tabId: number, connectInfo: object): runtime.Port
chrome.tabs.create(createProperties: object, callback: function)
chrome.tabs.detectLanguage(tabId?: number, callback: function)
chrome.tabs.discard(tabId: number, callback: function)
chrome.tabs.duplicate(tabId: number, callback: function)
chrome.tabs.executeScript(tabId?: number, details: extensionTypes.InjectDetails, callback: function)
chrome.tabs.get(tabId: number, callback: function)
chrome.tabs.getAllInWindow(windowId?: number, callback: function)
chrome.tabs.getCurrent(callback: function)
chrome.tabs.getSelected(windowId?: number, callback: function)
chrome.tabs.getZoom(tabId?: number, callback: function)
chrome.tabs.getZoomSettings(tabId?: number, callback: function)
chrome.tabs.goBack(tabId: number, callback: function)
chrome.tabs.goForward(tabId: number, callback: function)
chrome.tabs.group(options: object, callback: function)
chrome.tabs.highlight(highlightInfo: object, callback: function)
chrome.tabs.insertCSS(tabId?: number, details: extensionTypes.InjectDetails, callback: function)
chrome.tabs.move(tabIds: number | number[], moveProperties: object, callback: function)
chrome.tabs.query(queryInfo: object, callback: function)
chrome.tabs.reload(tabId: number, reloadProperties: object, callback: function)
chrome.tabs.remove(tabIds: number | number[], callback: function)
chrome.tabs.removeCSS(tabId?: number, details: extensionTypes.DeleteInjectionDetails, callback: function)
chrome.tabs.sendMessage(tabId: number, message: any, options: object, responseCallback: function)
chrome.tabs.sendRequest(tabId: number, request: any, responseCallback: function)
chrome.tabs.setZoom(tabId?: number, zoomFactor: number, callback: function)
chrome.tabs.setZoomSettings(tabId?: number, zoomSettings: ZoomSettings, callback: function)
chrome.tabs.ungroup(tabIds: number | number[], callback: function)
chrome.tabs.update(tabId?: number, updateProperties: object, callback: function)
- Events
Types
MutedInfo
The tab's muted state and the reason for the last state change.
Properties
- extensionIdstring optional
The ID of the extension that changed the muted state. Not set if an extension was not the reason the muted state last changed.
- mutedboolean
Whether the tab is muted (prevented from playing sound). The tab may be muted even if it has not played or is not currently playing sound. Equivalent to whether the 'muted' audio indicator is showing.
- reasonMutedInfoReason optional
The reason the tab was muted or unmuted. Not set if the tab's mute state has never been changed.
Tab
Properties
- activeboolean
Whether the tab is active in its window. Does not necessarily mean the window is focused.
- audibleboolean optional
Whether the tab has produced sound over the past couple of seconds (but it might not be heard if also muted). Equivalent to whether the 'speaker audio' indicator is showing.
- autoDiscardableboolean
Whether the tab can be discarded automatically by the browser when resources are low.
- discardedboolean
Whether the tab is discarded. A discarded tab is one whose content has been unloaded from memory, but is still visible in the tab strip. Its content is reloaded the next time it is activated.
- favIconUrlstring optional
The URL of the tab's favicon. This property is only present if the extension's manifest includes the
"tabs"
permission. It may also be an empty string if the tab is loading. - groupIdnumber
The ID of the group that the tab belongs to.
- heightnumber optional
The height of the tab in pixels.
- highlightedboolean
Whether the tab is highlighted.
- idnumber optional
The ID of the tab. Tab IDs are unique within a browser session. Under some circumstances a tab may not be assigned an ID; for example, when querying foreign tabs using the
sessions
API, in which case a session ID may be present. Tab ID can also be set tochrome.tabs.TAB_ID_NONE
for apps and devtools windows. - incognitoboolean
Whether the tab is in an incognito window.
- indexnumber
The zero-based index of the tab within its window.
- mutedInfoMutedInfo optional
The tab's muted state and the reason for the last state change.
- openerTabIdnumber optional
The ID of the tab that opened this tab, if any. This property is only present if the opener tab still exists.
- pendingUrlstring optional
The URL the tab is navigating to, before it has committed. This property is only present if the extension's manifest includes the
"tabs"
permission and there is a pending navigation. - pinnedboolean
Whether the tab is pinned.
- selectedboolean
Deprecated. Please use
Tab.highlighted
.Whether the tab is selected.
- sessionIdstring optional
The session ID used to uniquely identify a tab obtained from the
sessions
API. - statusTabStatus optional
The tab's loading status.
- titlestring optional
The title of the tab. This property is only present if the extension's manifest includes the
"tabs"
permission. - urlstring optional
The last committed URL of the main frame of the tab. This property is only present if the extension's manifest includes the
"tabs"
permission and may be an empty string if the tab has not yet committed. See alsoTab.pendingUrl
. - widthnumber optional
The width of the tab in pixels.
- windowIdnumber
The ID of the window that contains the tab.
ZoomSettings
Defines how zoom changes in a tab are handled and at what scope.
Properties
- defaultZoomFactornumber optional
Used to return the default zoom level for the current tab in calls to tabs.getZoomSettings.
- modeZoomSettingsMode optional
Defines how zoom changes are handled, i.e., which entity is responsible for the actual scaling of the page; defaults to
automatic
. - scopeZoomSettingsScope optional
Defines whether zoom changes persist for the page's origin, or only take effect in this tab; defaults to
per-origin
when inautomatic
mode, andper-tab
otherwise.
MutedInfoReason
An event that caused a muted state change.
Enum
"user"
, "capture"
, or "extension"
TabStatus
The tab's loading status.
Enum
"unloaded"
, "loading"
, or "complete"
WindowType
The type of window.
Enum
"normal"
, "popup"
, "panel"
, "app"
, or "devtools"
ZoomSettingsMode
Defines how zoom changes are handled, i.e., which entity is responsible for the actual scaling of the page; defaults to automatic
.
Enum
"automatic"
, "manual"
, or "disabled"
ZoomSettingsScope
Defines whether zoom changes 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.
Enum
"per-origin"
, or "per-tab"
Properties
TAB_ID_NONE
An ID that represents the absence of a browser tab.
Value
Methods
captureVisibleTab
chrome.tabs.captureVisibleTab(windowId?: number, options?: extensionTypes.ImageDetails, callback: function)
Captures the visible area of the currently active tab in the specified window. In order to call this method, the extension must have either the <all_urls> permission or the activeTab permission. In addition to sites that extensions can normally access, this method allows extensions to capture sensitive sites that are otherwise restricted, including chrome:-scheme pages, other extensions' pages, and data: URLs. These sensitive sites can only be captured with the activeTab permission. File URLs may be captured only if the extension has been granted file access.
Parameters
- windowIdnumber optional
The target window. Defaults to the current window.
- optionsextensionTypes.ImageDetails optional
- callbackfunction
The callback parameter should be a function that looks like this:
(dataUrl: string) => {...}
- dataUrlstring
A data URL that encodes an image of the visible area of the captured tab. May be assigned to the 'src' property of an HTML
img
element for display.
connect
chrome.tabs.connect(tabId: number, connectInfo: object): runtime.Port
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.
Parameters
- tabIdnumber
- connectInfoobject
- frameIdnumber optional
Open a port to a specific frame identified by
frameId
instead of all frames in the tab. - namestring optional
Is passed into onConnect for content scripts that are listening for the connection event.
Returns
- returns
A port that can be used to communicate with the content scripts running in the specified tab. The port's
runtime.Port
event is fired if the tab closes or does not exist.
create
chrome.tabs.create(createProperties: object, callback: function)
Creates a new tab.
Parameters
- createPropertiesobject
- activeboolean optional
Whether the tab should become the active tab in the window. Does not affect whether the window is focused (see
windows.update
). Defaults to true. - indexnumber optional
The position the tab should take in the window. The provided value is clamped to between zero and the number of tabs in the window.
- openerTabIdnumber optional
The ID of the tab that opened this tab. If specified, the opener tab must be in the same window as the newly created tab.
- pinnedboolean optional
Whether the tab should be pinned. Defaults to false
- selectedboolean optional
Deprecated. Please use active.
Whether the tab should become the selected tab in the window. Defaults to true
- urlstring optional
The URL to initially navigate the tab to. Fully-qualified URLs must include a scheme (i.e., 'http://www.google.com', not 'www.google.com'). Relative URLs are relative to the current page within the extension. Defaults to the New Tab Page.
- windowIdnumber optional
The window in which to create the new tab. Defaults to the current window.
- callbackfunction
detectLanguage
chrome.tabs.detectLanguage(tabId?: number, callback: function)
Detects the primary language of the content in a tab.
Parameters
- tabIdnumber optional
Defaults to the active tab of the current window.
- callbackfunction
The callback parameter should be a function that looks like this:
(language: string) => {...}
- languagestring
An ISO language code such as
en
orfr
. For a complete list of languages supported by this method, see kLanguageInfoTable. The second to fourth columns are checked and the first non-NULL value is returned, except for Simplified Chinese for whichzh-CN
is returned. For an unknown/undefined language,und
is returned.
discard
chrome.tabs.discard(tabId: number, callback: function)
Discards a tab from memory. Discarded tabs are still visible on the tab strip and are reloaded when activated.
Parameters
- tabIdnumber
The ID of the tab to be discarded. If specified, the tab is discarded unless it is active or already discarded. If omitted, the browser discards the least important tab. This can fail if no discardable tabs exist.
- callbackfunction
duplicate
chrome.tabs.duplicate(tabId: number, callback: function)
Duplicates a tab.
Parameters
- tabIdnumber
The ID of the tab to duplicate.
- callbackfunction
executeScript
chrome.tabs.executeScript(tabId?: number, details: extensionTypes.InjectDetails, callback: function)
Injects JavaScript code into a page. For details, see the programmatic injection section of the content scripts doc.
Parameters
- tabIdnumber optional
The ID of the tab in which to run the script; defaults to the active tab of the current window.
- details
Details of the script to run. Either the code or the file property must be set, but both may not be set at the same time.
- callbackfunction
Called after all the JavaScript has been executed.
The callback parameter should be a function that looks like this:
(result: any[]) => {...}
- resultany[]
The result of the script in every injected frame.
get
chrome.tabs.get(tabId: number, callback: function)
Retrieves details about the specified tab.
getAllInWindow
chrome.tabs.getAllInWindow(windowId?: number, callback: function)
Deprecated. Please use query
{windowId: windowId}
.
Gets details about all tabs in the specified window.
Parameters
- windowIdnumber optional
Defaults to the current window.
- callbackfunction
getCurrent
chrome.tabs.getCurrent(callback: function)
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).
getSelected
chrome.tabs.getSelected(windowId?: number, callback: function)
Deprecated. Please use query
{active: true}
.
Gets the tab that is selected in the specified window.
Parameters
- windowIdnumber optional
Defaults to the current window.
- callbackfunction
getZoom
chrome.tabs.getZoom(tabId?: number, callback: function)
Gets the current zoom factor of a specified tab.
Parameters
- tabIdnumber optional
The ID of the tab to get the current zoom factor from; defaults to the active tab of the current window.
- callbackfunction
Called with the tab's current zoom factor after it has been fetched.
The callback parameter should be a function that looks like this:
(zoomFactor: number) => {...}
- zoomFactornumber
The tab's current zoom factor.
getZoomSettings
chrome.tabs.getZoomSettings(tabId?: number, callback: function)
Gets the current zoom settings of a specified tab.
Parameters
- tabIdnumber optional
The ID of the tab to get the current zoom settings from; defaults to the active tab of the current window.
- callbackfunction
Called with the tab's current zoom settings.
The callback parameter should be a function that looks like this:
(zoomSettings: ZoomSettings) => {...}
- zoomSettings
The tab's current zoom settings.
goBack
chrome.tabs.goBack(tabId: number, callback: function)
Go back to the previous page, if one is available.
Parameters
- tabIdnumber
The ID of the tab to navigate back; defaults to the selected tab of the current window.
- callbackfunction
The callback parameter should be a function that looks like this:
() => {...}
goForward
chrome.tabs.goForward(tabId: number, callback: function)
Go foward to the next page, if one is available.
Parameters
- tabIdnumber
The ID of the tab to navigate forward; defaults to the selected tab of the current window.
- callbackfunction
The callback parameter should be a function that looks like this:
() => {...}
group
chrome.tabs.group(options: object, callback: function)
Adds one or more tabs to a specified group, or if no group is specified, adds the given tabs to a newly created group.
Parameters
- optionsobject
- createPropertiesobject optional
Configurations for creating a group. Cannot be used if groupId is already specified.
- windowIdnumber optional
The window of the new group. Defaults to the current window.
- groupIdnumber optional
The ID of the group to add the tabs to. If not specified, a new group will be created.
- tabIdsnumber | number[]
The tab ID or list of tab IDs to add to the specified group.
- callbackfunction
The callback parameter should be a function that looks like this:
(groupId: number) => {...}
- groupIdnumber
The ID of the group that the tabs were added to.
highlight
chrome.tabs.highlight(highlightInfo: object, callback: function)
Highlights the given tabs and focuses on the first of group. Will appear to do nothing if the specified tab is currently active.
Parameters
- highlightInfoobject
- tabsnumber[] | number
One or more tab indices to highlight.
- windowIdnumber optional
The window that contains the tabs.
- callbackfunction
The callback parameter should be a function that looks like this:
(window: windows.Window) => {...}
- window
Contains details about the window whose tabs were highlighted.
insertCSS
chrome.tabs.insertCSS(tabId?: number, details: extensionTypes.InjectDetails, callback: function)
Injects CSS into a page. For details, see the programmatic injection section of the content scripts doc.
Parameters
- tabIdnumber optional
The ID of the tab in which to insert the CSS; defaults to the active tab of the current window.
- details
Details of the CSS text to insert. Either the code or the file property must be set, but both may not be set at the same time.
- callbackfunction
Called when all the CSS has been inserted.
The callback parameter should be a function that looks like this:
() => {...}
move
chrome.tabs.move(tabIds: number | number[], moveProperties: object, callback: function)
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.
Parameters
- tabIdsnumber | number[]
The tab ID or list of tab IDs to move.
- movePropertiesobject
- indexnumber
The position to move the window to. Use
-1
to place the tab at the end of the window. - windowIdnumber optional
Defaults to the window the tab is currently in.
- callbackfunction
query
chrome.tabs.query(queryInfo: object, callback: function)
Gets all tabs that have the specified properties, or all tabs if no properties are specified.
Parameters
- queryInfoobject
- activeboolean optional
Whether the tabs are active in their windows.
- audibleboolean optional
Whether the tabs are audible.
- autoDiscardableboolean optional
Whether the tabs can be discarded automatically by the browser when resources are low.
- currentWindowboolean optional
Whether the tabs are in the current window.
- discardedboolean optional
Whether the tabs are discarded. A discarded tab is one whose content has been unloaded from memory, but is still visible in the tab strip. Its content is reloaded the next time it is activated.
- groupIdnumber optional
The ID of the group that the tabs are in, or
tabGroups.TAB_GROUP_ID_NONE
for ungrouped tabs. - highlightedboolean optional
Whether the tabs are highlighted.
- indexnumber optional
The position of the tabs within their windows.
- lastFocusedWindowboolean optional
Whether the tabs are in the last focused window.
- mutedboolean optional
Whether the tabs are muted.
- pinnedboolean optional
Whether the tabs are pinned.
- statusTabStatus optional
The tab loading status.
- titlestring optional
Match page titles against a pattern. This property is ignored if the extension does not have the
"tabs"
permission. - urlstring | string[] optional
Match tabs against one or more URL patterns. Fragment identifiers are not matched. This property is ignored if the extension does not have the
"tabs"
permission. - windowIdnumber optional
The ID of the parent window, or
windows.WINDOW_ID_CURRENT
for the current window. - windowTypeWindowType optional
The type of window the tabs are in.
- callbackfunction
reload
chrome.tabs.reload(tabId: number, reloadProperties: object, callback: function)
Reload a tab.
Parameters
- tabIdnumber
The ID of the tab to reload; defaults to the selected tab of the current window.
- reloadPropertiesobject
- bypassCacheboolean optional
Whether to bypass local caching. Defaults to
false
.
- callbackfunction
The callback parameter should be a function that looks like this:
() => {...}
remove
chrome.tabs.remove(tabIds: number | number[], callback: function)
Closes one or more tabs.
Parameters
- tabIdsnumber | number[]
The tab ID or list of tab IDs to close.
- callbackfunction
The callback parameter should be a function that looks like this:
() => {...}
removeCSS
chrome.tabs.removeCSS(tabId?: number, details: extensionTypes.DeleteInjectionDetails, callback: function)
Removes from a page CSS that was previously injected by a call to insertCSS
.
Parameters
- tabIdnumber optional
The ID of the tab from which to remove the CSS; defaults to the active tab of the current window.
Details of the CSS text to remove. Either the code or the file property must be set, but both may not be set at the same time.
- callbackfunction
Called when all the CSS has been removed.
The callback parameter should be a function that looks like this:
() => {...}
sendMessage
chrome.tabs.sendMessage(tabId: number, message: any, options: object, responseCallback: function)
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.
Parameters
- tabIdnumber
- messageany
The message to send. This message should be a JSON-ifiable object.
- optionsobject
- frameIdnumber optional
Send a message to a specific frame identified by
frameId
instead of all frames in the tab.
- responseCallbackfunction
The responseCallback function looks like this:
responseCallback(response: any) => {...}
- responseany
The JSON response object sent by the handler of the message. If an error occurs while connecting to the specified tab, the callback is called with no arguments and
runtime.lastError
is set to the error message.
sendRequest
chrome.tabs.sendRequest(tabId: number, request: any, responseCallback: function)
Deprecated. Please use runtime.sendMessage
.
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.
Parameters
- tabIdnumber
- requestany
- responseCallbackfunction
The responseCallback function looks like this:
responseCallback(response: any) => {...}
- responseany
The JSON response object sent by the handler of the request. If an error occurs while connecting to the specified tab, the callback is called with no arguments and
runtime.lastError
is set to the error message.
setZoom
chrome.tabs.setZoom(tabId?: number, zoomFactor: number, callback: function)
Zooms a specified tab.
Parameters
- tabIdnumber optional
The ID of the tab to zoom; defaults to the active tab of the current window.
- zoomFactornumber
The new zoom factor. A value of
0
sets the tab to its current default zoom factor. Values greater than0
specify a (possibly non-default) zoom factor for the tab. - callbackfunction
Called after the zoom factor has been changed.
The callback parameter should be a function that looks like this:
() => {...}
setZoomSettings
chrome.tabs.setZoomSettings(tabId?: number, zoomSettings: ZoomSettings, callback: function)
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.
Parameters
- tabIdnumber optional
The ID of the tab to change the zoom settings for; defaults to the active tab of the current window.
- zoomSettings
Defines how zoom changes are handled and at what scope.
- callbackfunction
Called after the zoom settings are changed.
The callback parameter should be a function that looks like this:
() => {...}
ungroup
chrome.tabs.ungroup(tabIds: number | number[], callback: function)
Removes one or more tabs from their respective groups. If any groups become empty, they are deleted.
Parameters
- tabIdsnumber | number[]
The tab ID or list of tab IDs to remove from their respective groups.
- callbackfunction
The callback parameter should be a function that looks like this:
() => {...}
update
chrome.tabs.update(tabId?: number, updateProperties: object, callback: function)
Modifies the properties of a tab. Properties that are not specified in updateProperties are not modified.
Parameters
- tabIdnumber optional
Defaults to the selected tab of the current window.
- updatePropertiesobject
- activeboolean optional
Whether the tab should be active. Does not affect whether the window is focused (see
windows.update
). - autoDiscardableboolean optional
Whether the tab should be discarded automatically by the browser when resources are low.
- highlightedboolean optional
Adds or removes the tab from the current selection.
- mutedboolean optional
Whether the tab should be muted.
- openerTabIdnumber optional
The ID of the tab that opened this tab. If specified, the opener tab must be in the same window as this tab.
- pinnedboolean optional
Whether the tab should be pinned.
- selectedboolean optional
Deprecated. Please use highlighted.
Whether the tab should be selected.
- urlstring optional
A URL to navigate the tab to. JavaScript URLs are not supported; use
executeScript
instead.
- callbackfunction
Events
onActivated
chrome.tabs.onActivated.addListener(listener: function)
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 so as to be notified when a URL is set.
Event
- listenerfunction
The listener parameter should be a function that looks like this:
(activeInfo: object) => {...}
- activeInfoobject
- tabIdnumber
The ID of the tab that has become active.
- windowIdnumber
The ID of the window the active tab changed inside of.
onActiveChanged
chrome.tabs.onActiveChanged.addListener(listener: function)
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 onUpdated
events so as to be notified when a URL is set.
Event
- listenerfunction
Deprecated. Please use
onActivated
.The listener parameter should be a function that looks like this:
(tabId: number, selectInfo: object) => {...}
- tabIdnumber
The ID of the tab that has become active.
- selectInfoobject
- windowIdnumber
The ID of the window the selected tab changed inside of.
onAttached
chrome.tabs.onAttached.addListener(listener: function)
Fired when a tab is attached to a window; for example, because it was moved between windows.
Event
- listenerfunction
The listener parameter should be a function that looks like this:
(tabId: number, attachInfo: object) => {...}
- tabIdnumber
- attachInfoobject
- newPositionnumber
- newWindowIdnumber
onCreated
chrome.tabs.onCreated.addListener(listener: function)
Fired when a tab is created. Note that the tab's URL may not be set at the time this event is fired, but you can listen to onUpdated events so as to be notified when a URL is set.
onDetached
chrome.tabs.onDetached.addListener(listener: function)
Fired when a tab is detached from a window; for example, because it was moved between windows.
Event
- listenerfunction
The listener parameter should be a function that looks like this:
(tabId: number, detachInfo: object) => {...}
- tabIdnumber
- detachInfoobject
- oldPositionnumber
- oldWindowIdnumber
onHighlightChanged
chrome.tabs.onHighlightChanged.addListener(listener: function)
Fired when the highlighted or selected tabs in a window changes.
Event
- listenerfunction
Deprecated. Please use
onHighlighted
.The listener parameter should be a function that looks like this:
(selectInfo: object) => {...}
- selectInfoobject
- tabIdsnumber[]
All highlighted tabs in the window.
- windowIdnumber
The window whose tabs changed.
onHighlighted
chrome.tabs.onHighlighted.addListener(listener: function)
Fired when the highlighted or selected tabs in a window changes.
Event
- listenerfunction
The listener parameter should be a function that looks like this:
(highlightInfo: object) => {...}
- highlightInfoobject
- tabIdsnumber[]
All highlighted tabs in the window.
- windowIdnumber
The window whose tabs changed.
onMoved
chrome.tabs.onMoved.addListener(listener: function)
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 to the manually-moved tab. This event is not fired when a tab is moved between windows; for details, see onDetached
.
Event
- listenerfunction
The listener parameter should be a function that looks like this:
(tabId: number, moveInfo: object) => {...}
- tabIdnumber
- moveInfoobject
- fromIndexnumber
- toIndexnumber
- windowIdnumber
onRemoved
chrome.tabs.onRemoved.addListener(listener: function)
Fired when a tab is closed.
Event
- listenerfunction
The listener parameter should be a function that looks like this:
(tabId: number, removeInfo: object) => {...}
- tabIdnumber
- removeInfoobject
- isWindowClosingboolean
True when the tab was closed because its parent window was closed.
- windowIdnumber
The window whose tab is closed.
onReplaced
chrome.tabs.onReplaced.addListener(listener: function)
Fired when a tab is replaced with another tab due to prerendering or instant.
Event
- listenerfunction
The listener parameter should be a function that looks like this:
(addedTabId: number, removedTabId: number) => {...}
- addedTabIdnumber
- removedTabIdnumber
onSelectionChanged
chrome.tabs.onSelectionChanged.addListener(listener: function)
Fires when the selected tab in a window changes.
Event
- listenerfunction
Deprecated. Please use
onActivated
.The listener parameter should be a function that looks like this:
(tabId: number, selectInfo: object) => {...}
- tabIdnumber
The ID of the tab that has become active.
- selectInfoobject
- windowIdnumber
The ID of the window the selected tab changed inside of.
onUpdated
chrome.tabs.onUpdated.addListener(listener: function)
Fired when a tab is updated.
Event
- listenerfunction
The listener parameter should be a function that looks like this:
(tabId: number, changeInfo: object, tab: Tab) => {...}
- tabIdnumber
- changeInfoobject
Lists the changes to the state of the tab that was updated.
- audibleboolean optional
The tab's new audible state.
- autoDiscardableboolean optional
The tab's new auto-discardable state.
- discardedboolean optional
The tab's new discarded state.
- favIconUrlstring optional
The tab's new favicon URL.
- groupIdnumber optional
The tab's new group.
- mutedInfoMutedInfo optional
The tab's new muted state and the reason for the change.
- pinnedboolean optional
The tab's new pinned state.
- statusTabStatus optional
The tab's loading status.
- titlestring optional
The tab's new title.
- urlstring optional
The tab's URL if it has changed.
- tab
Gives the state of the tab that was updated.
onZoomChange
chrome.tabs.onZoomChange.addListener(listener: function)
Fired when a tab is zoomed.
Event
- listenerfunction
The listener parameter should be a function that looks like this:
(ZoomChangeInfo: object) => {...}
- ZoomChangeInfoobject
- newZoomFactornumber
- oldZoomFactornumber
- tabIdnumber
- zoomSettings