For what you're doing specifically, you'll want to use an overlay to add an item to the right-click menu, which has id="contentAreaContextMenu". See https://developer.mozilla.org/en/DOM/selection for information on getting the text the user selected (if they didn't select anything then you probably don't need your menu item to show up at all) and then just do something like gBrowser.addTab('myurl.com?q=' + encodeURIComponent(selectedText));
发布评论
评论(2)
如何编写 Firefox 插件? 为您提供了一些获取位置开始了。
对于您具体要做的事情,您需要使用叠加层将项目添加到右键单击菜单,该菜单具有
id="contentAreaContextMenu"
。有关信息,请参阅 https://developer.mozilla.org/en/DOM/selection获取用户选择的文本(如果他们没有选择任何内容,那么您可能根本不需要显示菜单项),然后只需执行类似gBrowser.addTab('myurl.com?q ='+encodeURIComponent(selectedText));
How do I write a Firefox Addon? gives you some places to get started.
For what you're doing specifically, you'll want to use an overlay to add an item to the right-click menu, which has
id="contentAreaContextMenu"
. See https://developer.mozilla.org/en/DOM/selection for information on getting the text the user selected (if they didn't select anything then you probably don't need your menu item to show up at all) and then just do something likegBrowser.addTab('myurl.com?q=' + encodeURIComponent(selectedText));
最好的入门方法之一是遵循本教程:
http://www.borngeek.com /firefox/toolbar-tutorial/
然后找到与你的类似的其他扩展并解压缩并查看代码。
我建议查看:addons.mozilla.org/en-US/firefox/addon/8703/
希望能帮助您入门。
克里斯
One of the best ways to get started is follow this tutorial:
http://www.borngeek.com/firefox/toolbar-tutorial/
Then find other extensions similar to yours and unzip them and check out the code.
I suggest checking out: addons.mozilla.org/en-US/firefox/addon/8703/
Hope that helps you get started.
Chris