153Chapter 15 .Generic HTML Element (Web design tools) Objects A script

153Chapter 15 .Generic HTML Element Objects A script can also eliminate an event listener that was previously added by script. The removeEventListener() method takes the same parameters as addEventListener(), which means that you can turn off one listener without disturbing others. In fact, because you can add two listeners for the same event and listener function (one set to capture and one not a rare occurrence, indeed), the three parameters of the removeEventListener()enable you to specify precisely which listener to remove from an object. Unlike the event capture mechanism of NN4, the W3C DOM event model does not have a global capture mechanism for an event type regardless of target. And with respect to IE5, the addEventListener() method is closely analogous to the IE5 attachEvent() method. Also, event capture in IE5 is enabled via the setCapture() method. Both the W3C and IE5 event models use their separate syntaxes to bind objects to event handling functions, so the actual functions may be capable of serving both models with browser version branching required only for event binding. See Chapter 29 for more about event handling with these two event models. Example (with Listing 15-20) on the CD-ROM Related Items: attachEvent(), detachEvent(), dispatchEvent(), fireEvent(), removeEventListener() methods. appendChild(nodeObject) Returns: Node object reference. NN2 NN3 NN4 NN6 IE3/J1 IE3/J2 IE4 IE5 IE5.5 Compatibility Using the W3C DOM parent, node, and child terminology, you can create cross- browser code (for IE5+ and NN6) that modifies HTML content on the page. The appendChild() method inserts an element or text node (defined by other code that comes before it) as the new, last child of the current element. Aside from the more obvious application of adding a new child element to the end of a sequence of child nodes, the appendChild() method is also practical for building element objects and their content before appending, replacing, or inserting the element into an existing document. The document.createElement()method generates a reference to an element of whatever tag name you assign as that method s parameter. But this does nothing to populate the element s attributes or its content. While IE4+ offers nonstandard innerTextand innerHTML shortcut properties to assign content to an element (and NN6 provides innerHTML), the DOM standard recommends adding child nodes to the new element (for more details, see Chapter 14). For example, if you wish to create a B element and its content, you first create the element and then append a text node, as in the following sequence: On the CD-ROM elementObject.appendChild()
From our experience, we are can tell you that you can find a reliable and cheap webhost service at Java Web Hosting services.

Leave a Reply