280Part IIIDocument Objects ReferenceAn element always contains itself. (Web design seattle)

280Part IIIDocument Objects ReferenceAn element always contains itself. ExampleUsing The Evaluator (Chapter 13), see how the contains()method responds to the objectcombinations in each of the following statements as you enter them into the upper text box: document.body.contains(document.all.myP) document.all.myP.contains(document.all.item( myEM )) document.all.myEM.contains(document.all.myEM) document.all.myEM.contains(document.all.myP) Feel free to test other object combinations within this page. Related Items:item(), document.getElementById()methods. detachEvent() (See attachEvent()) dispatchEvent(eventObject) Returns:Boolean. Compatibility:WinIE-, MacIE-, NN6+, Moz1+, Safari1+ The dispatchEvent()method allows a script to fire an event aimed at any object capable ofsupporting that event. This is the W3C event model way of generalizing mechanisms that ear- lier browsers sometimes mimic with object methods such as click()and focus(). The process of generating one of these events is similar to the way a script generates a new nodeand inserts that node somewhere in the document object model. For events, however, the objectthat is created is an Eventobject, which is generated via the document.createEvent() method. An event generated in this manner is simply a specification about an event. Useproperties of an event object to supply specifics about the event, such as its coordinates ormouse button. Then dispatch the event to a target object by invoking that target object sdispatchEvent()method and passing the newly created Eventobject as the sole parameter. Interpreting the meaning of the Boolean value that the dispatchEvent()method returns is notstraightforward. The browser follows the dispatched event through whatever event propaga- tion is in effect for that object and event type (either bubbling or capture). If any of the eventlistener functions that are triggered by this dispatched event invoke the preventDefault() method, the dispatchEvent()method returns falseto indicate that the event did not triggerthe native action of the object; otherwise, the method returns true. Notice that this returnedvalue indicates nothing about propagation type or how many event listeners run as a result ofdispatching this event. Although the dispatchEvent()method is implemented in NN6, the browser does not yetprovide a way to generate new events from scratch. And if you attempt to redirect an exist- ing event to another object via the dispatchEvent()method, the browser is prone tocrashing. In other words, Mozilla-based browsers are much better candidates for scripts thatutilize dispatchEvent(). ExampleListing 15-25 demonstrates how to programmatically fire events using the W3C DOMdispatchEvent()method. Notice the syntax in the doDispatch()function for creating andCautionNoteelementObject.contains()