omnibox.onInputCancelled
当用户取消与扩展交互(比如点击地址栏之外的地方)时触发。
语法
js
browser.omnibox.onInputCancelled.addListener(listener)
browser.omnibox.onInputCancelled.removeListener(listener)
browser.omnibox.onInputCancelled.hasListener(listener)
事件有三个函数:
addListener(listener)
-
为此事件添加监听器。
removeListener(listener)
-
停止监听此事件。
listener
参数是要移除的监听器。 hasListener(listener)
-
检查是否已为此事件注册了
listener
。若正在监听,返回true
,否则返回false
。
addListener 语法
该监听器函数不需要传递任何参数。
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | ||||||
---|---|---|---|---|---|---|---|
onInputCancelled |
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.
示例
js
browser.omnibox.onInputCancelled.addListener(() => {
console.log("用户取消了会话");
});
备注:
该 API 基于 Chromium 的 chrome.omnibox
API。