[Greasemonkey] Re: dispatchEvent creates an error

Andre gm at andrecgn.de
Tue Aug 23 12:46:52 EDT 2005


right, but the link in my original mail points to an example:
http://www.mozilla.org/docs/dom/domref/dom_el_ref36.html#1028419

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

and it "isn't required anyway" ... yes, it is. I want to trigger the 
event the first time without user intervention. The event handler code 
uses variables from its closure, so I cannot just call it as a function.

Actually, I just re-wrote it and now I can call it, but how do I use 
dispatchEvent correctly?

Andre

from: Taral <taralx at gmail.com>
> On 8/23/05, Andre <gm at andrecgn.de> wrote:
> 
>>trigger.addEventListener("mouseover", eh_onmouseover, false); 
>> trigger.addEventListener("mouseout", eh_onmouseout, false);   
>> trigger.addEventListener("click", eh_onclick, false);         
>> trigger.dispatchEvent("click");                           
> 
> 
> My best guess: The error is from the last line, which is not right
> based on spec[1] and isn't required anyway. :)
> 
> [1] http://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113/events.html#Events-EventTarget-dispatchEvent
> 


More information about the Greasemonkey mailing list