[Greasemonkey] Re: dispatchEvent creates an error

Danil Ivanov mash-funky at mail.ru
Tue Aug 23 18:51:05 EDT 2005


> Example:
>         b = document.getElementById("button1");
>         res = b.dispatchEvent("click");

  //...
    var trigger = document.getElementById("button1");
    trigger.addEventListener("click", eh_onclick, false);
    var evt = document.createEvent("MouseEvents");
    evt.initMouseEvent("click", true, true, window,
        0, 0, 0, 0, 0, false, false, false, false, 0, null);
        // add values that you like
    trigger.dispatchEvent(evt);
    trigger.removeEventListener("click", eh_onclick, false);
  //...
  function eh_onclick(event) {
    //event.preventDefault();
    //event.stopPropagation();
    //...
  }


--
  BR, Danil Ivanov



More information about the Greasemonkey mailing list