[Greasemonkey] Calling a GreaseMonkey function from an "Onclick" event

Tobias Orterer orterer at gmail.com
Mon Jul 25 23:07:34 EDT 2005


myLink.onclick = functionname;

On 7/25/05, thomas Armstrong <tarmstrong at gmail.com> wrote:
> 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.
> _______________________________________________
> Greasemonkey mailing list
> Greasemonkey at mozdev.org
> http://mozdev.org/mailman/listinfo/greasemonkey
> 


-- 
PGP: 1D87 2E28 B3A5 EEAE 19EB  01C1 ED45 5B31 39AA 1669


More information about the Greasemonkey mailing list