tabs.get()
语法
js
let getting = browser.tabs.get(
tabId // 整数
)
参数
tabId
-
integer
。要获取的标签页的 ID。
返回值
示例
在标签页被激活时获取其信息:
js
async function logListener(info) {
try {
let tabInfo = await browser.tabs.get(info.tabId);
console.log(tabInfo);
} catch (error) {
console.error(error);
}
}
browser.tabs.onActivated.addListener(logListener);
示例扩展
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | ||||||
---|---|---|---|---|---|---|---|
get |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
备注:
此 API 基于 Chromium 的 chrome.tabs
API。本文档来自 Chromium 代码中的 tabs.json
。