我正在構建Safari擴展。Safari擴展 - 如何使用setContextEventUserInfo方法
在手冊中,在關於「添加上下文菜單項」,在該段「編程添加上下文菜單項」的頁面,它說:
You can add menu items to the contextual menu by responding to the extension version of the "contextmenu" event in your global page or an extension bar. If you stored information on the event by calling setContextEventUserInfo() in your injected script, you can use that information to help you decide what menu items to add.
現在,我在我的注入腳本上有這樣的代碼(因爲我試圖將選定的文本傳遞給後臺腳本):
function handleContextMenu(event) {
var htmlClip = getHtmlClip(event);
setContextEventUserInfo(htmlClip);
}
U nfortunately生成此錯誤:
ReferenceError: Can't find variable: setContextEventUserInfo
不幸的是,當我搜索setContextEventUserInfo谷歌,唯一的結果就是Safari的手冊頁!
可以請任何人向我解釋我應該如何使用setContextEventUserInfo方法?
謝謝。