如何从引导的 Firefox 插件添加 UI 元素
我正在为 Firefox 4 编写一个 Firefox 插件,它允许您创建引导插件(插件不需要重新启动浏览器),但是,它们不允许您使用 XUL 创建 UI 元素。 在工具菜单(使用 JavaScript)等地方创建 UI 元素的简单方法是什么?如何让我的插件打开一个新窗口来与浏览器交互?
I am writing a Firefox addon for Firefox 4 which allows you to create bootstraped addons (addons that do not require a restart of the browser), however, they do not allow you to use XUL to create UI elements.
What is an easy way to create UI elements in places like the tools menu (with JavaScript), and how do I make my addon open a new window to interface with the browser?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
现在这并不容易。您需要在浏览器窗口打开和关闭时跟踪它们,并通过 DOM API 手动将 UI 添加到每个窗口。
查看它是如何在 Addon(以前称为 Jetpack)SDK 中实现的:https://github.com/mozilla/addon-sdk/blob/master/packages/ addon-kit/lib/widget.js#L215(
browserManager
,以防行号发生变化)。It's not easy right now. You need to keep track of browser windows as they open and close and add your UI to each window manually via DOM APIs
See how it's implemented in the Addon (formerly Jetpack) SDK: https://github.com/mozilla/addon-sdk/blob/master/packages/addon-kit/lib/widget.js#L215 (
browserManager
, in case the line numbers change).Mozilla 附加 SDK(也称为 JetPack)已经发展到可用于创建整个附加组件。这些附加组件不仅创建起来快速且简单,而且无需重新启动。
使用 SDK 添加 UI 元素的最佳方法是使用 Widget API 可以让您轻松地向状态栏添加图标。还有其他用于上下文菜单和创建面板的 API。
The Mozilla Add-on SDK which is also known as JetPack has evolved to the point where it can be used to create entire add-ons. Not only are the add-ons fast and simple to create, but they are also restartless.
The best way to add UI elements with the SDK is to use the Widget API which will easily allow you to add an icon to the status bar. There are also other APIs for the context-menu and creating panels.