100 Part III . Document Objects Reference NN6-specific (Abyss web server)

100 Part III . Document Objects Reference NN6-specific features in that browser s implementation of JavaScript 1.5, link the .js library with the following tag: All scripts that follow belong in the .jslibrary. They re divided into two groups to allow for detailed discussion. The all property simulator Nearly every HTML element can be a container of other elements (with the exception of a handful of leaf nodes, such as
). The allproperty in IE returns a collection of references to all element objects nested inside the current object, no matter how deeply nested the containment hierarchy is. That s why the document.all reference is such a convenient way to access any element in the entire document that has an IDattribute. As illustrated earlier in the sidebar figure, the Nodestatic object is the object from which all elements are derived. That object s prototype is enhanced here because you have to make sure that all nodes, especially the document node, can acquire the allproperty. Listing 14-4a shows the segment of the library that defines the all property for the Node object prototype. Listing 14-4a: Simulator for the all Property if (!document.all) { Node.prototype.__defineGetter__( all , function() { if (document.getElementsByTagName( * ).length) { switch (this.nodeType) { case 9: return document.getElementsByTagName( * ) break case 1: return this.getElementsByTagName( * ) break } } return }) Node.prototype.__defineSetter__( all , function() {}) } This portion of the library exhibits a rare instance in which using object detection for document.alldoes the right thing now and in the future. The prototype should not execute if the browser loading the page already has a document.all property. The anonymous function first establishes a branch in the code only for the object model if it supports the wildcard parameter for the document.getElementsByTagName() method. The function then performs slightly different extractions depending on whether the node is the document (type 9) or an element (type 1). If the all property should be queried for any other kind of node, the returned value is an empty string. Each time the all property is accessed, the anonymous function executes to pick up all elements nested inside the current
Please visit Domain Name Hosting services for high quality webhost to host and run your jsp applications.

Leave a Reply