My minimal failing example of JavaScript for a Mozilla/Firefox extension using a content script adds a paragraph to web pages and tries to register a function i_clicked() to be called when the user clicks there.
console.log("step 0");
function i_clicked() {
console.log("step 2");
}
console.log("step 1");
let p = document.createElement("p");
p.textContent = "Click here";
p.setAttribute("onClick", "i_clicked()");
document.body.appendChild(p);
The log shows "step 0" and "step 1", but when I click on the paragraph, the console says: Uncaught ReferenceError: i_clicked is not defined. I conclude that the page cannot access the function I defined in the content script. How should this be done instead?
