282Part IIIDocument Objects ReferenceListing 15-25(continued) } // invoke (Web site developers)

282Part IIIDocument Objects ReferenceListing 15-25(continued) } // invoke fireEvent() on object whose ID is passed as parameterfunction doDispatch(objID, evt) { // create empty mouse eventvar newEvt = document.createEvent( MouseEvents ); // initialize as click with button ID 3newEvt.initMouseEvent( click , true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 3, null); // send event to element passed as paramdocument.getElementById(objID).dispatchEvent(newEvt); // don t let button clicks bubbleevt.stopPropagation(); }

fireEvent() Method



This is a paragraph (with a nested SPAN) that receives click events.


Control Panel

Cancel event bubbling.

Related Item:fireEvent()method. fireEvent( eventType [, eventObjectRef]) Returns:Boolean. Compatibility:WinIE5.5+, MacIE-, NN-, Moz-, Safari- While some objects have methods that emulate physical events (for example, the click() and focus()methods), WinIE5.5+ generalizes the mechanism by letting a script direct anyvalid event to any object. The fireEvent()method is the vehicle. One required parameter is the event type, formatted as a string. IE event types are coded justlike the property names for event handlers (for example, onclick, onmouseover, and so on). A second, optional parameter is a reference to an existing eventobject. This object can be anevent that some user or system action triggers (meaning that the fireEvent()method is in afunction invoked by an event handler). The existing event can also be an object created by theIE5.5+ document.createEventObject()method. In either case, the purpose of providing anelementObject.dispatchEvent()

Leave a Reply