admin管理员组文章数量:1414908
I'm trying to build a firefox addon & I want to add image/icon in the right click content menu , for example, firebug had an icon in the right click context menu,
I wanna do something similar, my addon also consists of menu items
structure of my addon in context menu :
[icon] [menu]
[menu item 1]
[menu item 2]
[menu item 3]
[menu item 4]
How can I do it ?
I'm trying to build a firefox addon & I want to add image/icon in the right click content menu , for example, firebug had an icon in the right click context menu,
I wanna do something similar, my addon also consists of menu items
structure of my addon in context menu :
[icon] [menu]
[menu item 1]
[menu item 2]
[menu item 3]
[menu item 4]
How can I do it ?
Share Improve this question edited Oct 17, 2014 at 9:46 Madhawa Priyashantha 9,9017 gold badges38 silver badges64 bronze badges asked Sep 11, 2010 at 10:49 user445045user4450452 Answers
Reset to default 6You have to set the image
attribute, give the element the class menu-iconic
and store the image so that you can access it.
XUL:
<menu id="someid" label='your label'
class="menu-iconic"
image='chrome://addon/skin/image.png'>
...
</menu>
JavaScript:
You can also set or change the image dynamically (get a reference to the element first):
menu.setAttribute('image', 'chrome://addon/skin/image.png');
You can add a context menu using the new Mozilla Add-ons SDK image using the image property
under Optional options:
just add the image attribute like this
var menuItem = contextMenu.Menu({
include: "*.stackoverflow.",
label: "do something",
image: "data:image/png;base64,iVBORw0KGgoAA ...",
context: contextMenu.SelectorContext('div.someclass'),
contentScriptFile: data.url("cs.js"),
items: [
contextMenu.Item({ label: "Item 1", data: "item1" }),
contextMenu.Item({ label: "Item 2", data: "item2" }),
contextMenu.Item({ label: "Item 3", data: "item3" })
]
});
image: The item's icon, a string URL. The URL can be remote, a reference to an image in the add-on's data directory, or a data URI.
Mozilla context menu help page for Addon SDK
本文标签: javascriptfirefox addonadding icon to context menuStack Overflow
版权声明:本文标题:javascript - firefox addon : adding icon to context menu - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745151810a2644955.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论