解析xml 在IE下是对的 在Chrom下是错的 为什么???

zyb_debug 2012-06-24 11:48:47
看代码

function loadXML(url)
{
var xmldoc = null;
if (document.implementation && document.implementation.createDocument)
{
xmldoc = document.implementation.createDocument("","",null);
xmldoc.async = false;
xmldoc.load(url);
}
else if(window.ActiveXObject)
{
xmldoc = new ActiveXObject("Microsoft.XMLDOM");
xmldoc.async = false;
xmldoc.load(url);
}
if (xmldoc != null)
{
if (xmldoc.parseError.errorCode != 0)
{
alert(xmldoc.parseError.reason);
return null;
}
}
return xmldoc;
}

function makeBuildHtmlContent(type)
{
//写构建步骤那块
var xmldoc = loadXML("SCRequestCfg.xml");
if (xmldoc == null)
{
alert("Load Xml failed\n");
return null;
}

var root = null;
root = document.getElementById(type);

if(root == null)
{
alert("load build root failed\n");
return null;
}
var table = document.createElement('table');
table.setAttribute("border","1");
root.appendChild(table);

var header = table.createTHead();
var headerrow = header.insertRow(0);
headerrow.insertCell(0).appendChild(document.createTextNode("构建名称"));
headerrow.insertCell(1).appendChild(document.createTextNode("权限级别"));
headerrow.insertCell(2).appendChild(document.createTextNode("预估耗时"));
headerrow.insertCell(3).appendChild(document.createTextNode("超时时间"));
headerrow.insertCell(4).appendChild(document.createTextNode("是否涉及加壳"));
......//后面的逻辑就不写了 就是更具xml里的内容动态创建一个表格

}



在Html是这么调用的 就是给div里根据xml内容填充东西 在IE8下显示正常 在chrome下就错了

<body onload="makeBuildHtmlContent('safebox_build_steps_all')">
<div id="wrapper">
<div id="safebox_build_steps_all">
</div>
</div>
</body>

...全文
250 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
cocca883 2013-03-29
  • 打赏
  • 举报
回复
怎么鼓捣的?
zyb_debug 2012-06-24
  • 打赏
  • 举报
回复
自己鼓捣了下,搞定了。
孟子E章 2012-06-24
  • 打赏
  • 举报
回复
请使用XMLRequestHttp实现,不要使用XMLDOM

87,904

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧