Methods
captureVisibleTab
void
chrome.tabs.captureVisibleTab(, integer
windowId, object
options, function
callback)
Undocumented.
Captures the visible area of the currently selected tab in the specified window.
Parameters
-
windowId
(
optional
Type
array of
integer
)
-
Undocumented.
- The target window. Defaults to the current window.
-
-
options
(
optional
Type
array of
object
)
-
Undocumented.
- Set parameters of image capture, such as the format of the resulting image. This parameter was added in version 5.0 . Earlier versions of chrome will throw an exception unless you omit it.
-
-
format
(
optional
Type
array of
string
)
-
Undocumented.
- The format of the resulting image. Default is jpeg.
-
-
quality
(
optional
Type
array of
integer
)
-
Undocumented.
- When format is 'jpeg', controls the quality of the resulting image. This value is ignored for PNG images. As quality is decreased, the resulting image will have more visual artifacts, and the number of bytes needed to store it will decrease.
-
-
callback
(
optional
Type
array of
function
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
Returns
Callback function
The callback parameter should specify a function
that looks like this:
If you specify the callback parameter, it should
specify a function that looks like this:
function(string dataUrl) {...});
-
dataUrl
(
optional
Type
array of
string
)
-
Undocumented.
- A data URL which encodes an image of the visible area of the captured tab. May be assigned to the 'src' property of an HTML Image element for display.
-
connect
Port
chrome.tabs.connect(, integer
tabId, object
connectInfo)
Undocumented.
Connects to the content script(s) in the specified tab. The chrome.extension.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
-
tabId
(
optional
Type
array of
integer
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
-
connectInfo
(
optional
Type
array of
object
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
-
name
(
optional
Type
array of
string
)
-
Undocumented.
- Will be passed into onConnect for content scripts that are listening for the connection event.
-
Returns
-
paramName
(
optional
Port
array of
paramType
)
-
Undocumented.
- A port that can be used to communicate with the content scripts running in the specified tab.
-
Callback function
The callback parameter should specify a function
that looks like this:
If you specify the callback parameter, it should
specify a function that looks like this:
function(Type param1, Type param2) {...});
create
void
chrome.tabs.create(, object
createProperties, function
callback)
Undocumented.
Creates a new tab.
Parameters
-
createProperties
(
optional
Type
array of
object
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
-
windowId
(
optional
Type
array of
integer
)
-
Undocumented.
- The window to create the new tab in. Defaults to the current window.
-
-
index
(
optional
Type
array of
integer
)
-
Undocumented.
- The position the tab should take in the window. The provided value will be clamped to between zero and the number of tabs in the window.
-
-
url
(
optional
Type
array of
string
)
-
Undocumented.
- The URL to navigate the tab to initially. Fully-qualified URLs must include a scheme (i.e. 'http://www.google.com', not 'www.google.com'). Relative URLs will be relative to the current page within the extension. Defaults to the New Tab Page.
-
-
selected
(
optional
Type
array of
boolean
)
-
Undocumented.
- Whether the tab should become the selected tab in the window. Defaults to true
-
-
callback
(
optional
Type
array of
function
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
Returns
Callback function
The callback parameter should specify a function
that looks like this:
If you specify the callback parameter, it should
specify a function that looks like this:
function(Tab tab) {...});
-
tab
(
optional
Tab
array of
paramType
)
-
Undocumented.
- Details about the created tab. Will contain the ID of the new tab.
-
detectLanguage
void
chrome.tabs.detectLanguage(, integer
tabId, function
callback)
Undocumented.
Detects the primary language of the content in a tab.
Parameters
-
tabId
(
optional
Type
array of
integer
)
-
Undocumented.
- Defaults to the selected tab of the current window.
-
-
callback
(
optional
Type
array of
function
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
Returns
Callback function
The callback parameter should specify a function
that looks like this:
If you specify the callback parameter, it should
specify a function that looks like this:
function(string language) {...});
-
language
(
optional
Type
array of
string
)
-
Undocumented.
- An ISO language code such as
en or fr. For a complete list of languages supported by this method, see kLanguageInfoTable. The 2nd to 4th columns will be checked and the first non-NULL value will be returned except for Simplified Chinese for which zh-CN will be returned. For an unknown language, und will be returned.
-
executeScript
void
chrome.tabs.executeScript(, integer
tabId, object
details, function
callback)
Undocumented.
Injects JavaScript code into a page. For details, see the programmatic injection section of the content scripts doc.
Parameters
-
tabId
(
optional
Type
array of
integer
)
-
Undocumented.
- The ID of the tab in which to run the script; defaults to the selected tab of the current window.
-
-
details
(
optional
Type
array of
object
)
-
Undocumented.
- 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.
-
-
code
(
optional
Type
array of
string
)
-
Undocumented.
- JavaScript code to execute.
-
-
file
(
optional
Type
array of
string
)
-
Undocumented.
- JavaScript file to execute.
-
-
allFrames
(
optional
Type
array of
boolean
)
-
Undocumented.
- If allFrames is true, this function injects script into all frames of current page. By default, it's false and script is injected only into the top main frame.
-
-
callback
(
optional
Type
array of
function
)
-
Undocumented.
- Called after all the JavaScript has been executed.
-
Returns
Callback function
The callback parameter should specify a function
that looks like this:
If you specify the callback parameter, it should
specify a function that looks like this:
function() {...});
get
void
chrome.tabs.get(, integer
tabId, function
callback)
Undocumented.
Retrieves details about the specified tab.
Parameters
-
tabId
(
optional
Type
array of
integer
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
-
callback
(
optional
Type
array of
function
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
Returns
Callback function
The callback parameter should specify a function
that looks like this:
If you specify the callback parameter, it should
specify a function that looks like this:
function(Tab tab) {...});
-
tab
(
optional
Tab
array of
paramType
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
getAllInWindow
void
chrome.tabs.getAllInWindow(, integer
windowId, function
callback)
Undocumented.
Gets details about all tabs in the specified window.
Parameters
-
callback
(
optional
Type
array of
function
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
Returns
Callback function
The callback parameter should specify a function
that looks like this:
If you specify the callback parameter, it should
specify a function that looks like this:
function(array of Tab tabs) {...});
-
tabs
(
optional
Type
array of
Tab
array of
paramType
paramType
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
getCurrent
void
chrome.tabs.getCurrent(, function
callback)
Undocumented.
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).
Parameters
-
callback
(
optional
Type
array of
function
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
Returns
Callback function
The callback parameter should specify a function
that looks like this:
If you specify the callback parameter, it should
specify a function that looks like this:
function(Tab tab) {...});
-
tab
(
optional
Tab
array of
paramType
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
getSelected
void
chrome.tabs.getSelected(, integer
windowId, function
callback)
Undocumented.
Gets the tab that is selected in the specified window.
Parameters
-
callback
(
optional
Type
array of
function
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
Returns
Callback function
The callback parameter should specify a function
that looks like this:
If you specify the callback parameter, it should
specify a function that looks like this:
function(Tab tab) {...});
-
tab
(
optional
Tab
array of
paramType
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
insertCSS
void
chrome.tabs.insertCSS(, integer
tabId, object
details, function
callback)
Undocumented.
Injects CSS into a page. For details, see the programmatic injection section of the content scripts doc.
Parameters
-
tabId
(
optional
Type
array of
integer
)
-
Undocumented.
- The ID of the tab in which to insert the CSS; defaults to the selected tab of the current window.
-
-
details
(
optional
Type
array of
object
)
-
Undocumented.
- 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.
-
-
code
(
optional
Type
array of
string
)
-
Undocumented.
- CSS code to be injected.
-
-
file
(
optional
Type
array of
string
)
-
Undocumented.
- CSS file to be injected.
-
-
allFrames
(
optional
Type
array of
boolean
)
-
Undocumented.
- If allFrames is true, this function injects CSS text into all frames of current page. By default, it's false and CSS is injected only into the top main frame.
-
-
callback
(
optional
Type
array of
function
)
-
Undocumented.
- Called when all the CSS has been inserted.
-
Returns
Callback function
The callback parameter should specify a function
that looks like this:
If you specify the callback parameter, it should
specify a function that looks like this:
function() {...});
move
void
chrome.tabs.move(, integer
tabId, object
moveProperties, function
callback)
Undocumented.
Moves a tab 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
-
tabId
(
optional
Type
array of
integer
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
-
moveProperties
(
optional
Type
array of
object
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
-
windowId
(
optional
Type
array of
integer
)
-
Undocumented.
- Defaults to the window the tab is currently in.
-
-
index
(
optional
Type
array of
integer
)
-
Undocumented.
- The position to move the window to. The provided value will be clamped to between zero and the number of tabs in the window.
-
-
callback
(
optional
Type
array of
function
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
Returns
Callback function
The callback parameter should specify a function
that looks like this:
If you specify the callback parameter, it should
specify a function that looks like this:
function(Tab tab) {...});
-
tab
(
optional
Tab
array of
paramType
)
-
Undocumented.
- Details about the moved tab.
-
remove
void
chrome.tabs.remove(, integer
tabId, function
callback)
Undocumented.
Closes a tab.
Parameters
-
tabId
(
optional
Type
array of
integer
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
-
callback
(
optional
Type
array of
function
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
Returns
Callback function
The callback parameter should specify a function
that looks like this:
If you specify the callback parameter, it should
specify a function that looks like this:
function() {...});
sendRequest
void
chrome.tabs.sendRequest(, integer
tabId, any
request, function
responseCallback)
Undocumented.
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 chrome.extension.onRequest event is fired in each content script running in the specified tab for the current extension.
Parameters
-
tabId
(
optional
Type
array of
integer
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
-
request
(
optional
Type
array of
any
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
-
responseCallback
(
optional
Type
array of
function
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
Returns
Callback function
The callback parameter should specify a function
that looks like this:
If you specify the callback parameter, it should
specify a function that looks like this:
function(any response) {...});
-
response
(
optional
Type
array of
any
)
-
Undocumented.
- The JSON response object sent by the handler of the request.
-
update
void
chrome.tabs.update(, integer
tabId, object
updateProperties, function
callback)
Undocumented.
Modifies the properties of a tab. Properties that are not specified in updateProperties are not modified.
Parameters
-
tabId
(
optional
Type
array of
integer
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
-
updateProperties
(
optional
Type
array of
object
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
-
url
(
optional
Type
array of
string
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
-
selected
(
optional
Type
array of
boolean
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
-
callback
(
optional
Type
array of
function
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
Returns
Callback function
The callback parameter should specify a function
that looks like this:
If you specify the callback parameter, it should
specify a function that looks like this:
function(Tab tab) {...});
-
tab
(
optional
Tab
array of
paramType
)
-
Undocumented.
- Details about the updated tab.
-
Events
onAttached
chrome.tabs.onAttached.addListener(function(integer tabId, object attachInfo) {...});
Undocumented.
Fired when a tab is attached to a window, for example because it was moved between windows.
Parameters
-
tabId
(
optional
Type
array of
integer
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
-
attachInfo
(
optional
Type
array of
object
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
-
newWindowId
(
optional
Type
array of
integer
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
-
newPosition
(
optional
Type
array of
integer
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
onCreated
chrome.tabs.onCreated.addListener(function(Tab tab) {...});
Undocumented.
Fires when a tab is created.
Parameters
-
tab
(
optional
Tab
array of
paramType
)
-
Undocumented.
- Details of the tab that was created.
-
onDetached
chrome.tabs.onDetached.addListener(function(integer tabId, object detachInfo) {...});
Undocumented.
Fired when a tab is detached from a window, for example because it is being moved between windows.
Parameters
-
tabId
(
optional
Type
array of
integer
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
-
detachInfo
(
optional
Type
array of
object
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
-
oldWindowId
(
optional
Type
array of
integer
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
-
oldPosition
(
optional
Type
array of
integer
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
onMoved
chrome.tabs.onMoved.addListener(function(integer tabId, object moveInfo) {...});
Undocumented.
Fires 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 onDetached.
Parameters
-
tabId
(
optional
Type
array of
integer
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
-
moveInfo
(
optional
Type
array of
object
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
-
windowId
(
optional
Type
array of
integer
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
-
fromIndex
(
optional
Type
array of
integer
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
-
toIndex
(
optional
Type
array of
integer
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
onRemoved
chrome.tabs.onRemoved.addListener(function(integer tabId) {...});
Undocumented.
Fires when a tab is closed.
Parameters
-
tabId
(
optional
Type
array of
integer
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
onSelectionChanged
chrome.tabs.onSelectionChanged.addListener(function(integer tabId, object selectInfo) {...});
Undocumented.
Fires when the selected tab in a window changes.
Parameters
-
tabId
(
optional
Type
array of
integer
)
-
Undocumented.
- The ID of the tab that has become selected.
-
-
selectInfo
(
optional
Type
array of
object
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
-
windowId
(
optional
Type
array of
integer
)
-
Undocumented.
- The ID of the window the selected tab changed inside of.
-
onUpdated
chrome.tabs.onUpdated.addListener(function(integer tabId, object changeInfo, Tab tab) {...});
Undocumented.
Fires when a tab is updated.
Parameters
-
tabId
(
optional
Type
array of
integer
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
-
changeInfo
(
optional
Type
array of
object
)
-
Undocumented.
- Lists the changes to the state of the tab that was updated.
-
-
status
(
optional
Type
array of
string
)
-
Undocumented.
- The status of the tab. Can be either loading or complete.
-
-
url
(
optional
Type
array of
string
)
-
Undocumented.
- Only specified if the tab's URL changed.
-
-
tab
(
optional
Tab
array of
paramType
)
-
Undocumented.
- Gives the state of the tab that was updated.
-