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

Aaron Boodman zboogs at gmail.com
Mon Jul 25 23:47:48 EDT 2005

> 1) within my GM script modify the page to give the end user an interface
> 2) within my interface call a script within my GM script to grab data
> from other web services.

Your strategy will work fine.

var elm = document.createElement("a");
elm.onclick = handleClick;

function handleClick() {
  GM_xmlhttpRequest({ [1]

function handleLoad(details) {
  alert("wooha!\n" + details.responseText);

Basically, just avoid the on* attributes.

[1] That is, after we have a release which has this function again.


More information about the Greasemonkey mailing list