How to add UI elements from a bootstraped Firefox addon

有些话、适合烂在心里 提交于 2019-12-06 12:27:24

问题


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?


回答1:


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).




回答2:


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.



来源:https://stackoverflow.com/questions/4484719/how-to-add-ui-elements-from-a-bootstraped-firefox-addon

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!