I am currently working on developing a Firefox extension. I want to create an image at runtime on a web page. Although I can successfully display the image, I am facing an issue when trying to invoke a method upon clicking it. Below is the code I am using:
var _img = doc.createElement("img");
_img.setAttribute("id", "floatImage");
_img.setAttribute("src", "abc.jpg");
_img.setAttribute("onclick", "clickimage()");
document.body.append(_img);
function clickimage() { alert("click"); }