Hua*_*ang 3 firefox firefox-addon
我在MDN上看过这篇文章:
https:
//developer.mozilla.org/en/Places_utilities_for_JavaScript#Bookmark_Dialog
但是仍然不知道如何调用函数
showAddBookmarkUI()
我试过了PlacesUtils.showAddBookmarkUI(),但没办法.
从Firefox 4开始,这篇文章已经过时了.此功能现在在PlacesUIUtils模块,方法中实现showBookmarkDialog().你会这样称呼它:
Components.utils.import("resource://gre/modules/Services.jsm");
var uri = Services.io.newURI("http://example.com/", null, null);
Components.utils.import("resource:///modules/PlacesUIUtils.jsm");
PlacesUIUtils.showBookmarkDialog({
action: "add",
type: "bookmark",
uri: uri,
title: "Example bookmark"
}, window);
Run Code Online (Sandbox Code Playgroud)
这是一个内部模块,因此没有真正记录,API将来可能会再次发生变化.您可以在源代码中看到如何使用它的示例.顺便说一句,如果你真正想要打开的是书签列表而不是"添加书签"对话框,那么你这样做:
Components.utils.import("resource://gre/modules/Services.jsm");
var organizer = Services.wm.getMostRecentWindow("Places:Organizer");
if (!organizer)
{
// No currently open places window, so open one with the specified mode.
openDialog("chrome://browser/content/places/places.xul",
"", "chrome,toolbar=yes,dialog=no,resizable", "AllBookmarks");
}
else
{
organizer.PlacesOrganizer.selectLeftPaneQuery("AllBookmarks");
organizer.focus();
}
Run Code Online (Sandbox Code Playgroud)
(代码主要从PlacesCommandHook实现中复制).
| 归档时间: |
|
| 查看次数: |
542 次 |
| 最近记录: |