javascriptparameter-passingcontextmenuxuladd-on

How to pass link to javascript function via right-click menu?


I'm writing an add-on for Pale Moon web browser (Mozilla).

I have added the menu item to the right-click menu contentAreaContextMenu, which is the menu that appears when you right-click on a hyperlink.

My problem is that I don't know how to send the hyperlink to the called function.

I've tried:

oncommand="projectName.BrowserOverlay.sayLink(document.activeElement);"

But it returns an [object XULElement], and the properties seem to only reference the add-on and not the link that was clicked on.

How can I pass the link that was right-clicked on to open the contentAreaContextMenu to the function?


Solution

  • I had to hack another add-on to find the answer.

    Turns out I needed to call the function like this:

    oncommand="projectName.BrowserOverlay.sayLink(gContextMenu.linkURL);"