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=[];
progIDs[0]='Msxml2.XMLHTTP.3.0';
var i = 0;
/*@cc_on
progIDs = [ 'Msxml2.XMLHTTP.6.0', 'Msxml2.XMLHTTP.3.0']; //6.0 is better of 3.0
for (; i < progIDs.length; i++) {
try{
@*/
if (window.ActiveXObject){
var xmlDOM = new ActiveXObject(progIDs[i]);
xmlDOM.setProperty("SelectionLanguage", "XPath");//because 3.0 default is XSLPattern
return xmlDOM;
}
/*@cc_on
}
catch (ex) {
}
}
@*/
return null;
}


Enjoy ;)

Ps. stay tuned for a corrected version..
Update:
http://mykenta.blogspot.com/2006/11/latest-version-of-getxdoc-dont-work-in.html
Posta un commento