CHAPTER 8 SCRIPTING IN THE (Web design service) BROWSER 243
CHAPTER 8 SCRIPTING IN THE BROWSER 243 if (is_ie) { var blnSuccess = false; for (var i=0; i < arrMSXMLProgIDs.length && !blnSuccess; i++) { try { var oDOMDocument = new ActiveXObject(arrMSXMLProgIDs[i]); strMSXMLProgID = arrMSXMLProgIDs[i]; blnSuccess = true; } catch (oException) { } } if (!blnSuccess ){ blnFailed = true; strFailedReason = "No suitable MSXML library on machine."; } } Initializing in Mozilla The Mozilla initialization code is slightly more complicated. It makes use of JavaScript prototypes, which allow you to add methods or properties to objects at run-time. In this case, the code adds methods that mimic the way that MSXML behaves: Document.prototype.__load__ = Document.prototype.load; Document.prototype.load = _Moz_Document_load; Note that _Moz_Document_load is a function that the wrapper declares later. The preceding code replaces the default loadmethod in the Mozilla DOM with a new method, _Moz_Document_load(). It keeps a reference to the default method by first assigning it to a prototype of a different name, Document.prototype.__load__. The wrapper must do this because it still needs to call the original method from within the new method. From an object- oriented perspective, this is like overriding a method and then calling that method on the super/parent class within the new method implementation.The wrapper also declares a new event handler called onreadystatechange: Document.prototype.onreadystatechange = null; The wrapper initially assigns the event handler a nullvalue. Later, the wrapper attaches code that runs when the event fires. The final prototype declares a Getter method to get the value of a variable: Node.prototype.__defineGetter__("xml", _Moz_Node_getXML); A Getter method appears as a property to the end user, but is implemented as a function. You don t need a corresponding Setter method because the xml property is read-only.
Searching for affordable and proven webhost to host and run your servlet applications? Go to Linux Web Hosting services and you will find it.