giovedì, novembre 09, 2006

latest version of getXDOC don't work in IE 4 because in IE 4
try catch are not supported, but IE4 also know the CC
so we need a check for this..
and how can we make try catch invisible to IE4?
using a 'simple' eval
IE4 still don't work well, but is the better I can do ^_^;;

Also notice that the correct object for a XHR is
Msxml2.XMLHTTP, not DOMDocument!

getXDOC modified version:

function getXDOC(){
return new XMLHttpRequest();


return eval('(function(){try{return new ActiveXObject("Msxml2.XMLHTTP.6.0");}catch(e__x){return new ActiveXObject("Msxml2.XMLHTTP.3.0");}}())');
return new ActiveXObject('Msxml2.XMLHTTP.3.0');


Sorry Andrea, I use conditional compilation again -.-

giovedì, novembre 02, 2006

Final method to obtain a dom Document ?

after the reading of this post on IE Blog talking about using the right version of msxml I come of a possible solution to get the XMLHttpRequest:

function getXDOC(){
//W3C native Object
if (window.XMLHttpRequest)return new XMLHttpRequest();

//IE 4.0 fallback [try..catch]
var progIDs=[];
var i = 0;
progIDs = [ 'Msxml2.XMLHTTP.6.0', 'Msxml2.XMLHTTP.3.0']; //6.0 is better of 3.0
for (; i < progIDs.length; i++) {
if (window.ActiveXObject){
var xmlDOM = new ActiveXObject(progIDs[i]);
xmlDOM.setProperty("SelectionLanguage", "XPath");//because 3.0 default is XSLPattern
return xmlDOM;
catch (ex) {
return null;

Enjoy ;)

Ps. stay tuned for a corrected version..