javascript document createEvent( )

createEvent( ) NN 6 IE n/a 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.


  • viewer
    #1
    2010-02-01
    [Quote]
    wahhh,i am looking for this for a few days...
593,Nickname,Homepage or email,Comments here,Add comment