Reputation: 12585
I'm trying to develop a simple Firefox extension. I want the user to right click and the extension to save what element was clicked on (paragraph, image, etc.) in a variable. Then there will be a context menu item "Item A". When the user clicks on "Item A", it will call a function which will take into consideration which element the user has right clicked on.
This is the only code I have so far for the Menu Item:
var contextMenu = require("sdk/context-menu");
var menuItem = contextMenu.Item({
label: "Menu Item A",
contentScript: 'self.on("click", function () {'
+ 'Do something'
+ '});'
});
Thank you!
Upvotes: 2
Views: 992
Reputation: 37338
var contextMenu = require("sdk/context-menu");
var menuItem = contextMenu.Item({
label: "Menu Item A",
contentScript: 'self.on("click", function (node) {console.log("node is = ",node);});'
});
you were basically there, see the node argument in function, it console.logs it on click, so go to browser console and check the message there for details on what node is
Upvotes: 1