164 Part III .Document Objects Reference fireEvent( eventType [, eventObjectRef]) (My space web page)

164 Part III .Document Objects Reference fireEvent( eventType [, eventObjectRef]) Returns: Boolean. NN2 NN3 NN4 NN6 IE3/J1 IE3/J2 IE4 IE5 IE5.5 Compatibility While some objects have methods that emulate physical events (for example, the click() and focus()methods), IE5.5 generalizes the mechanism by letting a script direct any valid 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 just like 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 an event that some user or system action triggers (meaning that the fireEvent() method is in a function invoked by an event handler). The existing event can also be an object created by the IE5.5 document.createEventObject() method. In either case, the purpose of providing an existing event object is to set the properties of the event object that the fireEvent() method creates. The event type is defined by the method s first parameter, but if you have other properties to set (for example, coordinates or a keyboard key code), then those properties are picked up from the existing object. Here is an example of a sequence that creates a new mousedown event, stuffs some values into its properties, and then fires the event at an element on the page: var newEvent = document.createEventObject() newEvent.clientX = 100 newEvent.clientY = 30 newEvent.cancelBubble = false newEvent.button = 1 document.all.myElement.fireEvent( onmousedown , newEvent) Events generated by the fireEvent()method are just like regular IE window. event objects, and they have several important eventobject properties that the browser presets. Importantly, cancelBubbleis set to false and returnValueis set to true just like a regular user- or system-induced event. This means that if you want to prevent event bubbling and/or prevent the default action of the event s source element, then the event handler functions must set these eventobject properties just like normal event handling in IE. The fireEvent() method returns a Boolean value that the returnValue property of the event determines. If the returnValueproperty is set to false during event handling, then the fireEvent() method returns false. Under normal processing, the method returns true. Although the W3C DOM Level 2 event model includes the dispatchEvent() method to accommodate script-generated events (and Eventobject methods to create event objects), Microsoft has so far elected to ignore the standard recommendation. While there is some similarity between the basic operations of elementObject.fireEvent()
Go visit our java server pages services for a reliable, lowcost webhost to satisfy all your needs.

Leave a Reply