【发布时间】:2011-12-23 16:36:07
【问题描述】:
改变这些 html/javascript 以使用 ie9 的最佳方法是什么(没有 jquery),
<html>
<body>
<div id="xmls">
<xml id="myXml">
<bookstore>
<book category="COOKING">
<title lang="en">Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book>
</bookstore>
</xml>
</div>
<!-- ...more html -->
</body>
</html>
并使用脚本阅读此 html 部分
function readBooks() {
var doc = null;
try {
doc = document.getElementById("myXml").XMLDocument.documentElement.childNodes.length;
alert('msg =' + doc);
//i need child nodes to iterate and show values,
} catch (ex) {
alert("problems to load xml" + doc);
throw ex;
}
}
这些适用于 ie6、7、8。
但与 ie9 不是。
XMLDocument 属性未定义,
谢谢,
【问题讨论】:
-
对不起,我的xml被写入了html文档
-
我想你忘了提到具体问题是什么。你在IE9上试过吗?它不工作吗?如何?有什么错误吗?有什么意想不到的结果吗?
标签: javascript internet-explorer internet-explorer-9 dom