Xul: creating a right-click context menu for hyperlinks only

I had a question to ask about creating a firefox plugin, basically my goal is to do the following:

1) In my plugin I want to show the context menu item of the context menu only for links [ anchor tags] and hide the menu item for the rest of the page

2) How to add a dynamic list to my menu, i.e. dynamically add the number of menu list items depending on the user's choice.

Can someone point me in the right direction

Thank!

+5
source share
1 answer
  • contextmenu , , :

    window.addEventListener("contextmenu", function(e) { 
        var menu = document.getElementById('your-menu-id');
        if(e.target.nodeName == 'A') {
            menu.hidden = false;
        }
        else {
            menu.hidden = true;
        }
    }, false);
    

    menu .

  • menu appendItem.

+6

All Articles