日期:2014-05-16 浏览次数:20390 次
原来的写法:
?
this.loadxml = function(xml) { var xmlDoc; if (window.ActiveXObject) { xmlDoc = new ActiveXObject('Microsoft.XMLDOM'); xmlDoc.async = false; xmlDoc.load(xml); } else if (document.implementation && document.implementation.createDocument) { xmlDoc = document.implementation.createDocument('', '', null); xmlDoc.async = false; xmlDoc.load(xml); } else { return null; } return xmlDoc; };
?
修改后的写法:
?
this.loadxml = function(xml) { var xmlDoc; if (window.ActiveXObject) { xmlDoc = new ActiveXObject('Microsoft.XMLDOM'); xmlDoc.async = false; xmlDoc.load(xml); } else if (document.implementation && document.implementation.createDocument) { try{ xmlDoc = document.implementation.createDocument('', '', null); xmlDoc.async = false; xmlDoc.load(xml); } catch(e){ var xmlhttp = new window.XMLHttpRequest(); xmlhttp.open("GET",xml,false); xmlhttp.send(null); xmlDoc = xmlhttp.responseXML.documentElement; } } else { return null; } return xmlDoc; };
?