[Greasemonkey] Calling a GreaseMonkey function from an "Onclick"
event
thomas Armstrong
tarmstrong at gmail.com
Mon Jul 25 22:50:00 EDT 2005
Hi.
With GreaseMonkey, I add a link to the HTML document:
--------------------------
var myLink = document.createElement("a");
myLink.href = "#";
myLink.setAttribute("onClick", "myFunction();return false");
txt = document.createTextNode('Click Here!');
myLink.appendChild(txt);
myElement.parentNode.insertBefore(myLink, myElement);
---------------------------
myFunction() is declared within GreaseMonkey functions, and
the link is created OK. But when clicking on it, I get this
JavaScript error message:
------------------
Error: myFunction is not defined
------------------
I tested my tool by using JavaScript code on a normal webpage
and works OK. I don't know if I must call myFunction on a different way.
Any suggestion is appreciated. Regards.
More information about the Greasemonkey
mailing list