diff --git a/lib/OpenLayers/Format/WPSExecute.js b/lib/OpenLayers/Format/WPSExecute.js index 0795b0d180..15c294f381 100644 --- a/lib/OpenLayers/Format/WPSExecute.js +++ b/lib/OpenLayers/Format/WPSExecute.js @@ -80,7 +80,7 @@ OpenLayers.Format.WPSExecute = OpenLayers.Class(OpenLayers.Format.XML, */ write: function(options) { var doc; - if (window.ActiveXObject) { + if (OpenLayers.Format.XML.supportActiveX) { doc = new ActiveXObject("Microsoft.XMLDOM"); this.xmldom = doc; } else { diff --git a/lib/OpenLayers/Format/XML.js b/lib/OpenLayers/Format/XML.js index b3f60ce979..ddb3a436a9 100644 --- a/lib/OpenLayers/Format/XML.js +++ b/lib/OpenLayers/Format/XML.js @@ -81,7 +81,7 @@ OpenLayers.Format.XML = OpenLayers.Class(OpenLayers.Format, { * the object. */ initialize: function(options) { - if(window.ActiveXObject) { + if (OpenLayers.Format.XML.supportActiveX) { this.xmldom = new ActiveXObject("Microsoft.XMLDOM"); } OpenLayers.Format.prototype.initialize.apply(this, [options]); @@ -138,7 +138,7 @@ OpenLayers.Format.XML = OpenLayers.Class(OpenLayers.Format, { * Since we want to be able to call this method on the prototype * itself, this.xmldom may not exist even if in IE. */ - if(window.ActiveXObject && !this.xmldom) { + if (OpenLayers.Format.XML.supportActiveX && !this.xmldom) { xmldom = new ActiveXObject("Microsoft.XMLDOM"); } else { xmldom = this.xmldom; @@ -871,7 +871,7 @@ OpenLayers.Format.XML = OpenLayers.Class(OpenLayers.Format, { if (document.implementation && document.implementation.createDocument) { OpenLayers.Format.XML.document = document.implementation.createDocument("", "", null); - } else if (!this.xmldom && window.ActiveXObject) { + } else if (!this.xmldom && OpenLayers.Format.XML.supportActiveX) { this.xmldom = new ActiveXObject("Microsoft.XMLDOM"); } } @@ -916,3 +916,13 @@ OpenLayers.Format.XML.lookupNamespaceURI = OpenLayers.Function.bind( * like document.createCDATASection. */ OpenLayers.Format.XML.document = null; + +/** + * APIFunction: OpenLayers.Format.XML.supportActiveX + * Returns a poolean flag to check if this browser uses ActiveX. + */ +OpenLayers.Format.XML.supportActiveX = (function () { + return (Object.getOwnPropertyDescriptor && + Object.getOwnPropertyDescriptor(window, "ActiveXObject")) || + ("ActiveXObject" in window); +})();