本文介绍了Internet Explorer 11(IE 11)使用DOMParser中的parseFromString引发语法错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Chrome和Firefox上的网页上有一些Javascript,当在IE 11中进行测试时,它会失败。我在IE 11中使用调试工具(F12)查看了问题,并且以下代码出现故障;特别是当使用parseFromString抛出语法错误时: if(window.DOMParser)
{
parser = new DOMParser();
tmp = parser.parseFromString(resp,text / xml);
}
我可以解决这个问题吗?
解决方案
对于IE,这适用于我
xmlDoc = new的ActiveXObject( Microsoft.XMLDOM);
xmlDoc.async = false;
xmlDoc.loadXML(text);
来源:
I have some Javascript on a webpage which works fine in Chrome and Firefox; when testing in IE 11 however it fails. I viewed the problem in IE 11 with the debug tools (F12) and the following code was at fault; specifically when using parseFromString a 'Syntax Error' is thrown:
if (window.DOMParser)
{
parser = new DOMParser();
tmp = parser.parseFromString(resp, "text/xml");
}
Any way I can work around this?
解决方案
For IE this works for me
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async=false;
xmlDoc.loadXML(text);
source: http://www.w3schools.com/dom/dom_parser.asp
这篇关于Internet Explorer 11(IE 11)使用DOMParser中的parseFromString引发语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!