Javascript Reference
Categories: document

javascript document createEvent( )

@March 25, 2009, 3:46 a.m.
createEvent( ) Firefox/Netscape/NN 6 IE n/a Chrome/Safari/DOM 2

createEvent("eventType")

 

Generates in memory an instance of a W3C DOM Event object of a particular event category. After the generic event is created, it must be initialized (via one of several initialization methods) as a particular event type, along with other properties appropriate for the event category. The following sequence creates a mousedown event and sends it to an element:

var evt = document.createEvent("MouseEvents");
evt.initEvent("mousedown", true, true);
document.getElementById("myElement").dispatchEvent(evt);
 

Such an event might then be handed to an element (via the element's dispatchEvent( ) method) so that the element's event listener can process the event as if it had been generated by a user clicking the mouse button.

 
Parameters
 
eventType

String constant for one of the support event categories: HTMLEvents, KeyEvents (supported by Netscape 6, but not specified until DOM Level 3), MouseEvents, MutationEvents, or UIEvents.

 
Returned Value

Event object object reference.

wahhh,i am looking for this for a few days...
viewer - 2010-02-02

Powered by Linode.