[Greasemonkey] defined functions

Aaron Boodman zboogs at gmail.com
Tue Jul 19 13:32:11 EDT 2005


Set the innerHTML (without the onclick attribute)

Then do this:

document.getElementsByTagName( "center" )[0]
                  .getElementsByTagName("input")[0].onclick = foo;

- a


On 7/19/05, Tobias Orterer <orterer at gmail.com> wrote:
> test.user.js:
> ---
> [...]header[...]
> 
> function foo() {
>        alert("bar");
> }
> 
> document.getElementsByTagName( "center" )[0].innerHTML =
> "<form name=\"search\" onsubmit=\"return false;\">"
> + "<input type=\"text\" name=\"username\" />"
> + "<input type=\"submit\" name=\"submit\" value=\"suchen\"
> onclick=\"search();\" />"
> + "</form>" + document.getElementsByTagName( "center" )[0].innerHTML;
> 
> --
> 
> when i click the button, javascript says: "foo is not a function"
> ???
> 
> 
> 
> --
> PGP: 1D87 2E28 B3A5 EEAE 19EB  01C1 ED45 5B31 39AA 1669
> _______________________________________________
> Greasemonkey mailing list
> Greasemonkey at mozdev.org
> http://mozdev.org/mailman/listinfo/greasemonkey
>


More information about the Greasemonkey mailing list