xml嵌入在IE9中的html中 [英] xml embedded in html in IE9
问题描述
在我们的应用程序中,我们将xml动态嵌入到html("数据岛")中。
如果稍后在代码中,我尝试使用XMLDocument获取xml的内容财产
(代码是document.getElementById("some id")。XMLDocument),
< span style ="font-size:medium"> 我得到了异常,因为IE9中的这个属性是未定义的,但在以前版本的IE中它可以工作。
您可以在下面找到可以执行的示例并重新创建问题(您可以将compitability模式更改为8以查看示例的检索数据)
谢谢,
Polina
< html>
< meta http -equiv = QUOT;内容类型"含量=" text / html的; CHARSET = utf-8">
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; < META NAME =" GENERATOR" Content =" Microsoft Visual Studio 6.0"
< meta http-equiv =" X-UA-Compatible" content =" IE = 9 ">
<meta http-equiv="X-UA-Compatible" content="IE=9">
&NBSP; < LINK REL =" SHORTCUT ICON" HREF =" images / MainSite.ico"
< TITLE> Astea Alliance Enterprise< / TITLE>
< head>
< / head>
< body>
< script type =" text / javascript">
function _onClick()
{
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; var str ="< xml id ='workerxml0'name ='workerxml0'>< node> aaa< / node>< / xml>";
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; document.body.insertAdjacentHTML(" afterBegin",str);
alert(" typeof workerxml0.XMLDocument" + typeof(workerxml0.XMLDocument));
alert(" workerxml0.XMLDocument.xml" + workerxml0.XMLDocument.xml);
}
< / script>
< / body>
< button name =" btn" onclick ='_ onClick();'>点击< / button>
< / html>
推荐答案
什么如果删除x-ua元标记,则会发生。 (你没有文档类型声明......所有版本的Ie都将使用Quirks模式)
What happens if you remove the x-ua meta tag. (you do not have a document type declaration... all versions of Ie will use Quirks mode)
< meta http-equiv =英寸×UA兼容" content =" IE = 9 ">
<meta http-equiv="X-UA-Compatible" content="IE=9">
....您的示例页面包含只有Quirks模式的错误解析其他文档模式将尝试更正错误。
.... you sample page contains errors that only Quirks mode will parse other document modes will try to correct the error.
< / body>
< button name =" btn" onclick ='_ onClick();'>点击< / button>
< / html>
你有< button>身体结束标记之外的元素....
你可以学习关于这里的文档类型声明... http://w3schools.com/doctype.asp
只需添加x-ua元标记以强制IE浏览器使用Standards DocumentMode与使用符合标准的标记不同。
问候。
这篇关于xml嵌入在IE9中的html中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!