多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
# 标签 chrome标签模块被用于和浏览器的标签系统交互。此模块被用于创建,修改,重新排列浏览器中的标签。. ![Two tabs in a window](https://box.kancloud.cn/2015-12-28_5680ab0c98dca.png) ## Manifest 几乎所有chrome标签方法需要你在[extension manifest](manifest.html)中定义标签权限。例如: ``` { "name": "My extension", ... **"permissions": [ "tabs" ]**, ... } ``` 不需要"标签"权限的方法是:[create](#method-create) 和 [update](#method-update). ## 示例 你可以在[examples/api/tabs](http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/extensions/docs/examples/api/tabs/) 目录下找到运用标签模块的示例。在源代码中查看帮助或者示例,请查阅[Samples](samples.html) 。 ## API reference: chrome.tabs ### Properties <a></a> #### getLastError chrome.extensionlastError ### Methods #### captureVisibleTab void chrome.tabs.captureVisibleTab(, integer `windowId`, object `options`, function `callback`) Undocumented. 在特定窗口中,抓取当前选中标签的可视区域。 这要求必须在 [host permission](manifest.html#permissions) 中指定对标签URL的访问权限。 #### Parameters `windowId`_( optional enumerated Type array of integer )_ Undocumented. 目标窗口,默认值为[当前窗口](windows.html#current-window). This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `options`_( optional enumerated Type array of object )_ Undocumented. 设置抓取图像参数。设置图像抓取的参数,比如生成的图像的格式。 This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `format`_( optional enumerated Type array of string ["jpeg", "png"] )_ Undocumented. 生成的图像的格式。默认是jpeg。 This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `quality`_( optional enumerated Type array of integer )_ Undocumented. 如果格式是'jpeg',控制结果图像的质量。此参数对PNG图像无效。当质量降低的时候,抓取的画质会下降,需要存储的字节数也会递减。 This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `callback`_( optional enumerated Type array of function )_ Undocumented. Description of this parameter from the json schema. This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. #### Returns #### Callback function 回调 _参数_ 应该如下定义: If you specify the _callback_ parameter, it should specify a function that looks like this: ``` function(string dataUrl) {...}; ``` `dataUrl`_( optional enumerated Type array of string )_ Undocumented. 被抓取标签的可视区域的URL。此URL可能会作为图像的src属性。 This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. This function was added in version . If you require this function, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. #### connect Port chrome.tabs.connect(, integer `tabId`, object `connectInfo`) Undocumented. 连接到特定标签中的content script(s)。 事件 [chrome.extension.onConnect](extension.html#event-onConnect) 将被触发给每个指定页面上运行的content script扩展。了解更多请查看 [Content Script Messaging](content_scripts.html#host-page-communication)。 #### Parameters `tabId`_( optional enumerated Type array of integer )_ Undocumented. Description of this parameter from the json schema. This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `connectInfo`_( optional enumerated Type array of object )_ Undocumented. Description of this parameter from the json schema. This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `name`_( optional enumerated Type array of string )_ Undocumented. 会被传输到监听连接事件的content scirpt的onConnect函数当中。 This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. #### Returns `paramName`_( optional enumerated [Port](extension.html#type-Port) array of paramType )_ Undocumented. 可以和在指定标签中运行的内容脚本通信。当标签被关闭或者不存在时,端口的 [onDisconnect](extension.html#type-Port) 事件被触发。 This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. #### 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) {...}; ``` This function was added in version . If you require this function, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. #### create void chrome.tabs.create(, object `createProperties`, function `callback`) Undocumented. 创建新的标签。注: 无需请求manifest的标签权限,此方法也可以被使用。 #### Parameters `createProperties`_( optional enumerated Type array of object )_ Undocumented. Description of this parameter from the json schema. This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `windowId`_( optional enumerated Type array of integer )_ Undocumented. 创建新标签的目标窗口。默认是[当前窗口](windows.html#current-window) 。 This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `index`_( optional enumerated Type array of integer )_ Undocumented. 标签在窗口中的位置。 值在零至标签数量之间。 This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `url`_( optional enumerated Type array of string )_ Undocumented. 标签导航的初始页面。完整的URL 必须包含一个前缀 (如 'http://www.google.com', 不能写为 'www.google.com')。 相对 URL则与扩展所在的页面相对, 默认值为新标签页面。 This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `selected`_( optional enumerated Type array of boolean )_ Undocumented. 标签是否成为选中标签。默认为true。 This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `pinned`_( optional enumerated Type array of boolean )_ Undocumented. 标签是否被固定。默认值为false。 This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `callback`_( optional enumerated Type array of function )_ Undocumented. Description of this parameter from the json schema. This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. #### Returns #### Callback function The callback _parameter_ should specify a function that looks like this: 回调 _参数_ 应该如下定义: ``` function(Tab tab) {...}; ``` `tab`_( optional enumerated [Tab](tabs.html#type-Tab) array of paramType )_ Undocumented. 所创建的标签的细节,包含新标签的ID。 This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. This function was added in version . If you require this function, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. #### detectLanguage void chrome.tabs.detectLanguage(, integer `tabId`, function `callback`) Undocumented. 检测标签内容的主要语言。 #### Parameters `tabId`_( optional enumerated Type array of integer )_ Undocumented. 默认为"[当前窗口](windows.html#current-window)"所选定的标签。 This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `callback`_( optional enumerated Type array of function )_ Undocumented. Description of this parameter from the json schema. This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. #### Returns #### Callback function 回调 _参数_ 应该如下定义: If you specify the _callback_ parameter, it should specify a function that looks like this: ``` function(string language) {...}; ``` `language`_( optional enumerated Type array of string )_ Undocumented. ISO 语言编码,例如en 或者 fr。若要查看此方法支持的完整语言列表,请参阅[kLanguageInfoTable](http://src.chromium.org/viewvc/chrome/trunk/src/third_party/cld/languages/internal/languages.cc) 。第2列和第4列会被检测,而且第一个不为空的值会被返回。 简体中文是个例外,返回zh-CN。对于未知语言,返回und。 This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. This function was added in version . If you require this function, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. #### executeScript void chrome.tabs.executeScript(, integer `tabId`, object `details`, function `callback`) Undocumented. 向页面注入JavaScript 脚本执行。要了解详情,请查阅内容脚本文档的 [programmatic injection](content_scripts.html#pi) 部分。 #### Parameters `tabId`_( optional enumerated Type array of integer )_ Undocumented. 运行脚本的标签ID;默认为当前窗口所选中的标签。 This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `details`_( optional enumerated Type array of object )_ Undocumented. 要执行的脚本内容,可选code或者file,但不能同时选两者。 This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `code`_( optional enumerated Type array of string )_ Undocumented. 要执行的脚本代码。 This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `file`_( optional enumerated Type array of string )_ Undocumented. 要执行的脚本文件。 This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `allFrames`_( optional enumerated Type array of boolean )_ Undocumented. true的时候,给所有frame执行脚本。默认为false,只给顶级frame执行脚本。 This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `callback`_( optional enumerated Type array of function )_ Undocumented. 所有脚本执行后会被调用的回调。 This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. #### Returns #### Callback function The callback _parameter_ should specify a function that looks like this: 回调 _参数_ 应该如下定义: ``` function() {...}; ``` This function was added in version . If you require this function, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. #### get void chrome.tabs.get(, integer `tabId`, function `callback`) Undocumented. 获取指定标签的细节信息。 #### Parameters `tabId`_( optional enumerated Type array of integer )_ Undocumented. Description of this parameter from the json schema. This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `callback`_( optional enumerated Type array of function )_ Undocumented. Description of this parameter from the json schema. This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. #### Returns #### 回调函数 回调 _参数_ 应该如下定义: If you specify the _callback_ parameter, it should specify a function that looks like this: ``` function(Tab tab) {...}; ``` `tab`_( optional enumerated [Tab](tabs.html#type-Tab) array of paramType )_ Undocumented. Description of this parameter from the json schema. This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. This function was added in version . If you require this function, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. #### getAllInWindow void chrome.tabs.getAllInWindow(, integer `windowId`, function `callback`) Undocumented. 获取指定窗口所有标签的细节信息。 #### Parameters `windowId`_( optional enumerated Type array of integer )_ Undocumented. 默认为[当前窗口](windows.html#current-window)。 This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `callback`_( optional enumerated Type array of function )_ Undocumented. Description of this parameter from the json schema. This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. #### Returns #### 回调函数 T 回调 _参数_ 应该如下定义: If you specify the _callback_ parameter, it should specify a function that looks like this: ``` function(array of Tab tabs) {...}; ``` `tabs`_( optional enumerated Type array of [Tab](tabs.html#type-Tab) array of paramType paramType )_ Undocumented. Description of this parameter from the json schema. This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. This function was added in version . If you require this function, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. #### getCurrent void chrome.tabs.getCurrent(, function `callback`) Undocumented. 获取生成脚本调用的标签。此函数不适用于脚本被非标签内容调用的情况。(例如: 背景页 或者 弹出视图) 。 #### Parameters `callback`_( optional enumerated Type array of function )_ Undocumented. Description of this parameter from the json schema. This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. #### Returns #### 回调函数 回调 _参数_ 应该如下定义: If you specify the _callback_ parameter, it should specify a function that looks like this: ``` function(Tab tab) {...}; ``` `tab`_( optional enumerated [Tab](tabs.html#type-Tab) array of paramType )_ Undocumented. Description of this parameter from the json schema. This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. This function was added in version . If you require this function, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. #### getSelected void chrome.tabs.getSelected(, integer `windowId`, function `callback`) Undocumented. 获取特定窗口指定的标签。 #### Parameters `windowId`_( optional enumerated Type array of integer )_ Undocumented. 默认为[当前窗口](windows.html#current-window)。 This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `callback`_( optional enumerated Type array of function )_ Undocumented. Description of this parameter from the json schema. This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. #### Returns #### 回调函数 回调 _参数_ 应该如下定义: If you specify the _callback_ parameter, it should specify a function that looks like this: ``` function(Tab tab) {...}; ``` `tab`_( optional enumerated [Tab](tabs.html#type-Tab) array of paramType )_ Undocumented. Description of this parameter from the json schema. This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. This function was added in version . If you require this function, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. #### insertCSS void chrome.tabs.insertCSS(, integer `tabId`, object `details`, function `callback`) Undocumented. 向页面注入CSS。要了解详情,请参阅内容脚本文档中的 [programmatic injection](content_scripts.html#pi) 部分。 #### Parameters `tabId`_( optional enumerated Type array of integer )_ Undocumented. 要注入CSS的标签ID;默认为当前窗口选定的标签。 This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `details`_( optional enumerated Type array of object )_ Undocumented. 要注入的CSS的内容,可选code或者file,但不能同时选两者。 This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `code`_( optional enumerated Type array of string )_ Undocumented. 要注入的CSS代码。 This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `file`_( optional enumerated Type array of string )_ Undocumented. 要注入的CSS文件。 This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `allFrames`_( optional enumerated Type array of boolean )_ Undocumented. true的时候,给所有frame注入CSS。默认为false,只给顶级frame注入CSS。 This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `callback`_( optional enumerated Type array of function )_ Undocumented. 当所有的CSS 被注入后,回调被调用。 This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. #### Returns #### 回调函数 回调 _参数_ 应该如下定义: ``` function() {...}; ``` This function was added in version . If you require this function, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. #### move void chrome.tabs.move(, integer `tabId`, object `moveProperties`, function `callback`) Undocumented. 把标签移动至窗口内特定的位置,或者移至一个新窗口。请注意只能在普通窗口之间切移(window.type === "normal") 。 #### Parameters `tabId`_( optional enumerated Type array of integer )_ Undocumented. Description of this parameter from the json schema. This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `moveProperties`_( optional enumerated Type array of object )_ Undocumented. Description of this parameter from the json schema. This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `windowId`_( optional enumerated Type array of integer )_ Undocumented. 默认为标签所在的窗口。 This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `index`_( optional enumerated Type array of integer )_ Undocumented. 移动到的目标窗口位置。赋值必须在零至目标窗口的标签数目之间。 This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `callback`_( optional enumerated Type array of function )_ Undocumented. Description of this parameter from the json schema. This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. #### Returns #### 回调函数 回调 _参数_ 应该如下定义: ``` function(Tab tab) {...}; ``` `tab`_( optional enumerated [Tab](tabs.html#type-Tab) array of paramType )_ Undocumented. 所被移动的标签细节。 This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. This function was added in version . If you require this function, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. #### remove void chrome.tabs.remove(, integer `tabId`, function `callback`) Undocumented. 关闭标签。 #### Parameters `tabId`_( optional enumerated Type array of integer )_ Undocumented. Description of this parameter from the json schema. This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `callback`_( optional enumerated Type array of function )_ Undocumented. Description of this parameter from the json schema. This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. #### Returns #### 回调函数 回调 _参数_ 应该如下定义: ``` function() {...}; ``` This function was added in version . If you require this function, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. #### sendRequest void chrome.tabs.sendRequest(, integer `tabId`, any `request`, function `responseCallback`) Undocumented. 向特定的标签content script发送一个的请求, 并在响应返回时,可附带一个回调。在所有content script响应请求后, [chrome.extension.onRequest](extension.html#event-onRequest) 事件将会为当前扩展触发。 #### Parameters `tabId`_( optional enumerated Type array of integer )_ Undocumented. Description of this parameter from the json schema. This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `request`_( optional enumerated Type array of any )_ Undocumented. Description of this parameter from the json schema. This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `responseCallback`_( optional enumerated Type array of function )_ Undocumented. Description of this parameter from the json schema. This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. ##### Parameters `response`_( optional enumerated Type array of any )_ Undocumented. 响应的JSON对象。如果错误发生,回调将不会有参数。并会在 [chrome.extension.lastError](extension.html#property-lastError) 产生一个错误。 This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. #### Returns #### 回调函数 回调 _参数_ 应该如下定义: ``` function(any response) {...}; ``` `response`_( optional enumerated Type array of any )_ Undocumented. 响应的JSON对象。如果错误发生,回调将不会有参数。并会在 [chrome.extension.lastError](extension.html#property-lastError) 产生一个错误。 This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. This function was added in version . If you require this function, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. #### update void chrome.tabs.update(, integer `tabId`, object `updateProperties`, function `callback`) Undocumented. 修改标签的属性。没有在updateProperties 中指定的属性不会被修改。注:即使没有向manifest 请求'tabs'权限,这个方法依然适用。 #### Parameters `tabId`_( optional enumerated Type array of integer )_ Undocumented. Description of this parameter from the json schema. This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `updateProperties`_( optional enumerated Type array of object )_ Undocumented. Description of this parameter from the json schema. This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `url`_( optional enumerated Type array of undefined )_ Undocumented. 让标签浏览的URL。 This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `selected`_( optional enumerated Type array of boolean )_ Undocumented. 标签是否应被选中。 This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `pinned`_( optional enumerated Type array of boolean )_ Undocumented. 标签是否应被固定。 This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `callback`_( optional enumerated Type array of function )_ Undocumented. Description of this parameter from the json schema. This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. #### Returns #### 回调函数 The callback _parameter_ should specify a function that looks like this: 回调 _参数_ 应该如下定义: ``` function(Tab tab) {...}; ``` `tab`_( optional enumerated [Tab](tabs.html#type-Tab) array of paramType )_ Undocumented. 被更新的标签细节。 This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. This function was added in version . If you require this function, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. ### Events #### onAttached chrome.tabs.onAttached.addListener(function(integer tabId, object attachInfo) {...}); Undocumented. 当标签附着在窗口上,此事件被触发。例如,此事件会发生在标签在窗口之前移动时。 #### Parameters `tabId`_( optional enumerated Type array of integer )_ Undocumented. Description of this parameter from the json schema. This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `attachInfo`_( optional enumerated Type array of object )_ Undocumented. Description of this parameter from the json schema. This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `newWindowId`_( optional enumerated Type array of integer )_ Undocumented. Description of this parameter from the json schema. This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `newPosition`_( optional enumerated Type array of integer )_ Undocumented. Description of this parameter from the json schema. This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. #### onCreated chrome.tabs.onCreated.addListener(function(Tab tab) {...}); Undocumented. 标签创建时,此事件触发。请注意,当事件触发时,标签的 URL 可能没有被设置, 但是当URL被设置时,可以通过onUpdated 事件接听。 #### Parameters `tab`_( optional enumerated [Tab](tabs.html#type-Tab) array of paramType )_ Undocumented. 标签创建的细节。 This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. #### onDetached chrome.tabs.onDetached.addListener(function(integer tabId, object detachInfo) {...}); Undocumented. 当标签从窗口脱离时,此事件被触发,例如标签在窗口之间移动。 #### Parameters `tabId`_( optional enumerated Type array of integer )_ Undocumented. Description of this parameter from the json schema. This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `detachInfo`_( optional enumerated Type array of object )_ Undocumented. Description of this parameter from the json schema. This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `oldWindowId`_( optional enumerated Type array of integer )_ Undocumented. Description of this parameter from the json schema. This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `oldPosition`_( optional enumerated Type array of integer )_ Undocumented. Description of this parameter from the json schema. This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. #### onMoved chrome.tabs.onMoved.addListener(function(integer tabId, object moveInfo) {...}); Undocumented. 当标签在窗口内移动时,此事件被触发。只有一个移动事件被触发,给用户直接移动的标签。其他响应移动事件的标签不触发移动事件。 请参阅 [onDetached](tabs.html#event-onDetached).查看详情。 #### Parameters `tabId`_( optional enumerated Type array of integer )_ Undocumented. Description of this parameter from the json schema. This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `moveInfo`_( optional enumerated Type array of object )_ Undocumented. Description of this parameter from the json schema. This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `windowId`_( optional enumerated Type array of integer )_ Undocumented. Description of this parameter from the json schema. This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `fromIndex`_( optional enumerated Type array of integer )_ Undocumented. Description of this parameter from the json schema. This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `toIndex`_( optional enumerated Type array of integer )_ Undocumented. Description of this parameter from the json schema. This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. #### onRemoved chrome.tabs.onRemoved.addListener(function(integer tabId, object removeInfo) {...}); Undocumented. 标签关闭时被触发。 #### Parameters `tabId`_( optional enumerated Type array of integer )_ Undocumented. Description of this parameter from the json schema. This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `removeInfo`_( optional enumerated Type array of object )_ Undocumented. Description of this parameter from the json schema. This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `isWindowClosing`_( optional enumerated Type array of boolean )_ Undocumented. 当窗口被关闭,标签随之被关闭时,此参数为true。 This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. #### onSelectionChanged chrome.tabs.onSelectionChanged.addListener(function(integer tabId, object selectInfo) {...}); Undocumented. 当窗口选中的标签改变时,此事件触发 #### Parameters `tabId`_( optional enumerated Type array of integer )_ Undocumented. 被选中标签的ID。 This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `selectInfo`_( optional enumerated Type array of object )_ Undocumented. Description of this parameter from the json schema. This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `windowId`_( optional enumerated Type array of integer )_ Undocumented. 标签发生变化的窗口ID。 This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. #### onUpdated chrome.tabs.onUpdated.addListener(function(integer tabId, object changeInfo, Tab tab) {...}); Undocumented. 当标签更新时,此事件被触发。 #### Parameters `tabId`_( optional enumerated Type array of integer )_ Undocumented. Description of this parameter from the json schema. This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `changeInfo`_( optional enumerated Type array of object )_ Undocumented. 列出标签更新时的状态。 This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `status`_( optional enumerated Type array of string )_ Undocumented. 标签的状态。可以为 _loading_ or _complete_。 This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `url`_( optional enumerated Type array of string )_ Undocumented. 经历变化的标签的URL。 This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `pinned`_( optional enumerated Type array of boolean )_ Undocumented. 标签被锁定的新状态。 This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `tab`_( optional enumerated [Tab](tabs.html#type-Tab) array of paramType )_ Undocumented. 更新的标签的状态。 This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. ### Types #### Tab `paramName`_( optional enumerated Type array of object )_ Undocumented. Description of this parameter from the json schema. This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `id`_( optional enumerated Type array of integer )_ Undocumented. 标签ID。在一个浏览器会话内, 标签ID是唯一的。 This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `index`_( optional enumerated Type array of integer )_ Undocumented. 窗口内从零开始的标签索引。 This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `windowId`_( optional enumerated Type array of integer )_ Undocumented. 标签所在窗口的窗口ID。 This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `selected`_( optional enumerated Type array of boolean )_ Undocumented. 标签是否被选中。 This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `pinned`_( optional enumerated Type array of boolean )_ Undocumented. 标签是否被锁定。 This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `url`_( optional enumerated Type array of string )_ Undocumented. 标签所显示的URL。 This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `title`_( optional enumerated Type array of string )_ Undocumented. 标签的标题。当标签被加载时,标题可能不能被成功获取。 This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `favIconUrl`_( optional enumerated Type array of string )_ Undocumented. 标签收藏夹图标的URL。当标签被加载时,图标可能不能被成功获取。 This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `status`_( optional enumerated Type array of string )_ Undocumented. 可以被设置为 _loading_ 或者 _complete_。 This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version. `incognito`_( optional enumerated Type array of boolean )_ Undocumented. 可以被设置为 _loading_ 或者 _complete_. This parameter was added in version . You must omit this parameter in earlier versions, and you may omit it in any version. If you require this parameter, the manifest key [minimum_chrome_version](manifest.html#minimum_chrome_version) can ensure that your extension won't be run in an earlier browser version.