Safari扩展事件:SafariBeforeSearchEvent

Safari扩展事件:SafariBeforeSearchEvent,safari,safari-extension,safari6,Safari,Safari Extension,Safari6,我看到SafariBeforeSearchEvent事件在智能搜索字段执行搜索之前触发。所以我开始尝试,但它不起作用或者我的代码错了。这是我的密码: safari.application.addEventListener("SafariBeforeSearchEvent", handleBeforeSearch, false); function handleBeforeSearch(event) { alert("Test"); } 当我使用智能搜索字段搜索某个内容时,不会显示任何

我看到
SafariBeforeSearchEvent
事件在智能搜索字段执行搜索之前触发。所以我开始尝试,但它不起作用或者我的代码错了。这是我的密码:

safari.application.addEventListener("SafariBeforeSearchEvent", handleBeforeSearch, false);

function handleBeforeSearch(event) {
    alert("Test");
}
当我使用智能搜索字段搜索某个内容时,不会显示任何警报。这是为什么?

事件的名称是“beforeSearch”,而不是“SafariBeforeSearchEvent”(事件的类别)

此外,如果要在应用程序级别侦听此事件,可能需要将捕获参数设置为“true”


请参阅。

看起来此API不再可用

safari.application.addEventListener("beforeSearch", handleBeforeSearch, true);