Tabs

Manifest

Examples

Methods

captureVisibleTab

connect

create

detectLanguage

executeScript

get

getSelected

Warning

(#_#)

  • 已经废除!

getCurrent

highlight

insertCSS

insertCSS

query

reload

remove

sendRequest

sendMessage

chrome.tabs.sendMessage(integer tabId, any message, function responseCallback)

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 chrome.extension.onMessage event is fired in each content script running in the specified tab for the current extension. Parameters

tabId ( integer ) message ( any ) responseCallback ( optional function ) Parameters

response ( any ) The JSON response object sent by the handler of the message. If an error occurs while connecting to the specified tab, the callback will be called with no arguments and chrome.extension.lastError will be set to the error message.

Callback function

If you specify the callback parameter, it should specify a function that looks like this:

function(any response) {...};

response ( any ) The JSON response object sent by the handler of the message. If an error occurs while connecting to the specified tab, the callback will be called with no arguments and chrome.extension.lastError will be set to the error message.

update

chrome.tabs.update(integer tabId, object updateProperties, function callback)

Modifies the properties of a tab. Properties that are not specified in updateProperties are not modified. Note: This function can be used without requesting the ‘tabs’ permission in the manifest.

param tabId:( optional integer )

Defaults to the selected tab of the current window. :param updateProperties:( object )

url ( optional string ) A URL to navigate the tab to. active ( optional boolean ) Whether the tab should be active. highlighted ( optional boolean ) Adds or removes the tab from the current selection. pinned ( optional boolean ) Whether the tab should be pinned. openerTabId ( optional integer ) The ID of the tab that opened this tab. If specified, the opener tab must be in the same window as this tab.

callback ( optional function )

Callback function

If you specify the callback parameter, it should specify a function that looks like this:

function(Tab tab) {...};

tab ( optional Tab ) Details about the updated tab, or null if the ‘tabs’ permission has not been requested.

Events

onActivated

onAttached

onCreated

onDetached

onHighlighted

onMoved

onRemoved

onSelectionChanged

弃用 .. warning:: ToT

弃用!

chrome.tabs.onSelectionChanged.addListener(function(integer tabId, object selectInfo) {...}));

当一个窗口中选定的标签页更改时发生。
事件处理函数参数
tabId ( integer )

    新选定标签页的标识符。

selectInfo ( object )

    windowId ( integer )

        选定标签页更改所在的窗口的标识符。

onUpdated

Types

Tab

See also

(^.^)

原文: Types