101Chapter 14 .Document Object Model Essentials node. Therefore, (Simple web server)
101Chapter 14 .Document Object Model Essentials node. Therefore, the collection returned by the allproperty is always up to date, even if the node structure of the current object changes after the document loads. While this simulator code provides NN6 scripts with IE4-like syntax for referencing elements, the collection returned by the native document.all in IE and calculated document.all in NN6 may not always have an identical length the collections are derived slightly differently. The important thing to know, however, is that by employing this prototype modifier in NN6, you have the ability to reference elements by their IDs in the form document.all.elementID. The content properties simulators The remaining code of this library lets NN6 use the same innerTextand outerHTMLproperties as IE4 for modifying all element objects. Listing 14-4b contains the NN6 JavaScript code that prepares the browser to set an element object s outerHTMLproperty, as well as get and set the innerTextproperties. The code again uses anonymous functions assigned to getterand setterbehaviors of prototype properties. Because the properties here apply only to HTML elements, the static object whose prototype is being modified is HTMLElement. All specific HTML element objects inherit properties and methods from the HTMLElementobject. All four prototype adjustment blocks are nested inside a condition that makes sure the static HTMLElementobject is exposed in the browser s object model (which it is in NN6+). All functions in Listing 14-4b use the W3C DOM Range object (Chapter 19). Two of them use a Netscape-proprietary method of the Rangeobject as a shortcut to converting a string into a node hierarchy. Listing 14-4b: Simulator for the innerText and outerHTML Properties if (HTMLElement) { HTMLElement.prototype.__defineSetter__( innerText , function (txt) { var rng = document.createRange() rng.selectNodeContents(this) rng.deleteContents() var newText = document.createTextNode(txt) this.appendChild(newText) return txt }) HTMLElement.prototype.__defineGetter__( innerText , function () { var rng = document.createRange() rng.selectNode(this) return rng.toString() }) HTMLElement.prototype.__defineSetter__( outerHTML , function (html) { var rng = document.createRange() rng.selectNode(this) var newHTML = rng.createContextualFragment(html) this.parentNode.replaceChild(newHTML,this) return html }) HTMLElement.prototype.__defineGetter__( outerHTML , function() {return }) }
If you are searching for cheap webhost for your web application, please visit MySQL5 Web Hosting services.