我已经看到在智能搜索字段执行搜索之前会触发SafariBeforeSearchEvent事件。所以我开始尝试它,但它不工作或我的代码是错误的。下面是我的代码:
safari.application.addEventListener("SafariBeforeSearchEvent", handleBeforeSearch, false);
function handleBeforeSearch(event) {
alert("Test");
}当我使用智能搜索字段搜索某些内容时,不会出现任何警告。为什么会这样呢?
发布于 2012-10-10 07:48:27
事件的名称是"beforeSearch",而不是"SafariBeforeSearchEvent“(这是事件的类)。
此外,如果要在应用程序级别侦听此事件,则可能需要将捕获参数设置为"true“。
safari.application.addEventListener("beforeSearch", handleBeforeSearch, true);请参阅documentation here。
发布于 2019-03-04 14:36:24
看起来在App-Extensions中这个API不再可用。
https://stackoverflow.com/questions/12798226
复制相似问题