2012-10-09 43 views
1

我在智能搜索字段执行搜索之前看到SafariBeforeSearchEvent事件触发。所以我开始尝试,但这不是工程或我的代码是错误的。这是我的代码:Safari扩展事件:SafariBeforeSearchEvent

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

function handleBeforeSearch(event) { 
    alert("Test"); 
} 

而当我使用智能搜索字段搜索某些内容时,不会显示任何提示。这是为什么?

回答

3

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

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

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

查看documentation here