同样一段代码为什么firefox可以,而chrome去不能执行 5
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/...
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<script type="text/javascript">
function loadXMLDoc(){
var xmlhttp;
if(window.XMLHttpRequest){//Internet Explorer 7+,Firefox,Chrome,Opera,Safari
xmlhttp=new XMLHttpRequest();
}else if(window.ActiveXObject){//Internet Explorer 5/6
xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');
}else{
alert('your browser does not support AJAX');
}
xmlhttp.onreadystatechange=function(){
if (xmlhttp.readyState==4 && xmlhttp.status==200){
XMLDoc=xmlhttp.responseXML;
txt='';
name=XMLDoc.getElementsByTagName("title");
for(i=0;i<name.length;i++){
txt=txt+(name[i].childNodes[0].nodeValue+"<br/>");
}
document.getElementById("div").innerHTML=txt;
}
}
xmlhttp.open('Get','xml.xml',true);
xmlhttp.send();
}
</script>
</head>
<body>
<div id="div"></div>
<input type="button" value="请求数据" onclick="loadXMLDoc()"/>
</body>
</html> 展开
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<script type="text/javascript">
function loadXMLDoc(){
var xmlhttp;
if(window.XMLHttpRequest){//Internet Explorer 7+,Firefox,Chrome,Opera,Safari
xmlhttp=new XMLHttpRequest();
}else if(window.ActiveXObject){//Internet Explorer 5/6
xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');
}else{
alert('your browser does not support AJAX');
}
xmlhttp.onreadystatechange=function(){
if (xmlhttp.readyState==4 && xmlhttp.status==200){
XMLDoc=xmlhttp.responseXML;
txt='';
name=XMLDoc.getElementsByTagName("title");
for(i=0;i<name.length;i++){
txt=txt+(name[i].childNodes[0].nodeValue+"<br/>");
}
document.getElementById("div").innerHTML=txt;
}
}
xmlhttp.open('Get','xml.xml',true);
xmlhttp.send();
}
</script>
</head>
<body>
<div id="div"></div>
<input type="button" value="请求数据" onclick="loadXMLDoc()"/>
</body>
</html> 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询