extension.getBackgroundPage()
若后台脚本在运行中,则返回后台页面的 Window。若脚本不在运行,则返回 null。
这是一个同步函数。
备注:
该方法不能在隐私浏览模式下使用——它总是返回 null。请考虑使用 runtime.sendMessage()
或 runtime.connect()
。更多信息请参见 Firefox bug 1329304。
语法
js
let page = browser.extension.getBackgroundPage()
参数
无。
返回值
object
。后台页面的 Window 或 null。
示例
示例扩展
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | ||||||
---|---|---|---|---|---|---|---|
getBackgroundPage |
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.extension
API。该文档衍生自 Chromium 代码中的 extension.json
。