244 CHAPTER (Most popular web site) 8 SCRIPTING IN THE BROWSER
244 CHAPTER 8 SCRIPTING IN THE BROWSER xDOM.createDocument() Method The xDOM.createDOMDocument() is the only method that you call with JavaScript in other words, it s a public method. This method determines which browser is being used and creates a DOMDocument object using the appropriate method for that browser. The method also attaches an event handler to the Mozilla loadevent so that you can raise this event in the same way as in IE: xDOM.createDOMDocument = function() { var oOutDOMDocument = null; if (is_gecko) { oOutDOMDocument = document.implementation.createDocument(”", “”, null); oOutDOMDocument.addEventListener(”load”, document_onload, false); } else if (is_ie) { oOutDOMDocument = new ActiveXObject(strMSXMLProgID); oOutDOMDocument.preserveWhite space = true; } return oOutDOMDocument; } Private xDOM Library Functions The remainder of the library file contains the implementations of the prototypes that you declared earlier. You can look through these to see how Mozilla natively handles some of its more advanced XML features. The first method implemented is the Mozilla version of the MSXML loadXML() method. This uses the XMLParser object that is included in the Mozilla XMLExtras library. This library ships with all Mozilla installations: function _Moz_Document_loadXML(strXML) { updateReadyState(this, 1); var oDOMParser = new DOMParser(); var oDOM = oDOMParser.parseFromString(strXML, “text/xml”); while (this.hasChildNodes()) this.removeChild(this.lastChild); for (var i=0; i < oDOM.childNodes.length; i++) { var oImportNode = this.importNode(oDOM.childNodes[i], true); this.appendChild(oImportNode); } fireOnLoad(this); } This method copies the nodes from the newly parsed DOM.
Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision J2ee Web Hosting services.