tabs.getZoom()
获取指定标签页的当前缩放因子。
这是一个返回 Promise
的异步函数。
语法
js
let gettingZoom = browser.tabs.getZoom(
tabId // 可选整数
)
参数
tabId
可选-
integer
。要获取当前缩放因子的标签页的 ID。默认为当前窗口的活动标签页。
返回值
一个 Promise
,其会兑现标签页的当前缩放因子,取值范围为 0.3 到 5。如果找不到标签页或发生其他错误,promise 将会以错误信息拒绝。
示例
获取当前标签页的缩放因子:
js
function onGot(zoom) {
console.log(zoom);
}
function onError(error) {
console.log(`发生错误:${error}`);
}
let gettingZoom = browser.tabs.getZoom();
gettingZoom.then(onGot, onError);
获取标签页 ID 为 2 的标签页的缩放因子:
js
function onGot(zoom) {
console.log(zoom);
}
function onError(error) {
console.log(`发生错误:${error}`);
}
let gettingZoom = browser.tabs.getZoom(2);
gettingZoom.then(onGot, onError);
示例扩展
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | ||||||
---|---|---|---|---|---|---|---|
getZoom |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No 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
。