Chrome无法加载XML问题求助
安全第一 2011-07-26 03:05:49 各位大大,这已经不是一个新问题,小弟已试过N多方法都不可行,以下是我的代码:
function loadXML(xmlFile) {
var xmlDoc;
if (window.ActiveXObject) {
xmlDoc = new ActiveXObject('Microsoft.XMLDOM');
xmlDoc.async = false;
xmlDoc.load(xmlFile);
}
else if (document.implementation && document.implementation.createDocument) {
var xmlhttp = new window.XMLHttpRequest();
xmlhttp.overrideMimeType("text/xml");
xmlhttp.open("GET", xmlFile, false);
xmlhttp.send(null);
xmlDom = xmlhttp.responseXML;
}
else {
return null;
}
return xmlDoc.documentElement;
}
function checkXMLDocObj(xmlFile) {
var xmlDoc = loadXML(xmlFile);
if (xmlDoc == null) {
alert('您的浏览器不支持xml文件读取');
window.location.href = '/index.aspx';
}
return xmlDoc;
}
var xmlDoc = checkXMLDocObj('xml/configuration.xml');
结果使用Chrome打开,总是提示我自己定义的信息“您的浏览器不支持xml文件读取”
看到好多人使用上述方法都可以了,为什么我就是不行??
对了,我的JavaScript脚本是加在ASPX文件中的。。。
PS:Chrome版本12.0.742.122