谷歌js读取xml到xmlDoc.load(xmlFile)时就停止了var xmlDoc;
if(window.ActiveXObject) {
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async=false;
xmlDoc.load(xmlFile);
}
else if(document.implementation&&document.implementation.createDocument){
xmlDoc=document.implementation.createDocument("", "",null);
xmlDoc.async=false; alert("aaa");
xmlDoc.load(xmlFile);
/*var xmlhttp = new window.XMLHttpRequest();
xmlhttp.open("GET", xmlFile, false);
xmlhttp.send(null);
xmlDoc = xmlhttp.responseXML;*/
} else{
alert('Your browser cannot handle this script');
}
return xmlDoc;
谷歌是否有另外的api
if(window.ActiveXObject) {
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async=false;
xmlDoc.load(xmlFile);
}
else if(document.implementation&&document.implementation.createDocument){
xmlDoc=document.implementation.createDocument("", "",null);
xmlDoc.async=false; alert("aaa");
xmlDoc.load(xmlFile);
/*var xmlhttp = new window.XMLHttpRequest();
xmlhttp.open("GET", xmlFile, false);
xmlhttp.send(null);
xmlDoc = xmlhttp.responseXML;*/
} else{
alert('Your browser cannot handle this script');
}
return xmlDoc;
谷歌是否有另外的api
这个URL用你网站的全路径试试
{
try //Internet Explorer
{
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
}
catch(e)
{
try //Firefox, Mozilla, Opera, etc.
{
xmlDoc=document.implementation.createDocument("","",null);
}
catch(e) {alert(e.message)}
}
try
{
xmlDoc.async=false;
xmlDoc.load(dname);
return(xmlDoc);
}
catch(e) {alert(e.message)}
return(null);
}function init() {
xmlDoc=loadXMLDoc("test.xml");}
Uncaught TypeError: Object #<Document> has no method 'load'有人知道为什么吗?
So you have to use XmlHttpRequests, which Chrome does support.
Off-Topic: I'm assuming this is a problem for Safari too.
上面是在google论坛上找到的.看来在google浏览器中只能够用xmlhttprequest 拿xml了