Where did you install Firefox from? Help Mozilla uncover 3rd party websites that offer problematic Firefox installation by taking part in our campaign. There will be swag, and you'll be featured in our blog if you manage to report at least 10 valid reports!

Cerca nel supporto

Attenzione alle mail truffa. Mozilla non chiederà mai di chiamare o mandare messaggi a un numero di telefono o di inviare dati personali. Segnalare qualsiasi attività sospetta utilizzando l'opzione “Segnala abuso”.

Learn More

Questa discussione è archiviata. Inserire una nuova richiesta se occorre aiuto.

How can i set correctly a Listener of contextMenus Clicked event?

  • 1 risposta
  • 1 ha questo problema
  • 1 visualizzazione
  • Ultima risposta di Alessandro

more options

Hello, i'm trying to develop an Add-on for firefox that permit to write on the textarea but i'm having some problems triggering the Click event on contextMenus option.

I'm using the standard format to understand how it works: Create element in contextMenus browser.contextMenus.create({

   id: "copy-link-to-clipboard",
   title: "Copy link to clipboard",
   contexts: ["all"],

});

Clicked event browser.contextMenus.onClicked.addListener((info, tab) => {

   if (info.menuItemId === "copy-link-to-clipboard") {
       console.log("test-1");
       let elem = browser.menus.getTargetElement(targetElementId);

let test = "test-2"; elem.textContent = test;

   }

});

This code doesn't work because i haven't an output in console, somebody can help me to understand where i wrong?

Hello, i'm trying to develop an Add-on for firefox that permit to write on the textarea but i'm having some problems triggering the Click event on contextMenus option. I'm using the standard format to understand how it works: ''Create element in contextMenus'' browser.contextMenus.create({ id: "copy-link-to-clipboard", title: "Copy link to clipboard", contexts: ["all"], }); ''Clicked event'' browser.contextMenus.onClicked.addListener((info, tab) => { if (info.menuItemId === "copy-link-to-clipboard") { console.log("test-1"); let elem = browser.menus.getTargetElement(targetElementId); let test = "test-2"; elem.textContent = test; } }); This code doesn't work because i haven't an output in console, somebody can help me to understand where i wrong?

Tutte le risposte (1)

more options

I tried this other code but it doesn't work too

browser.menus.create({

 id: "click-me",
 title: "Click me!",
 contexts: ["all"]

});

browser.menus.onClicked.addListener((info, tab) => {

 console.log("test");

});