pageAction.getTitle()
获取页面操作的标题。
这是一个返回 Promise
的异步函数。
语法
js
let gettingTitle = browser.pageAction.getTitle(
details // 对象
)
参数
返回值
Promise
,将以包含页面操作的标题的字符串兑现。
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | ||||||
---|---|---|---|---|---|---|---|
getTitle |
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.
示例
当用户点击页面操作的图标时记录其标题:
js
function gotTitle(title) {
console.log(`标题为 ${title}`);
}
browser.pageAction.onClicked.addListener((tab) => {
let gettingTitle = browser.pageAction.getTitle({
tabId: tab.id,
});
gettingTitle.then(gotTitle);
});
示例扩展
备注:
该 API 基于 Chromium 的 chrome.pageAction
API。本文衍生自 Chromium 代码中的 page_action.json
。