Internet Explorer 11 (IE 11) Throws Syntax Error using parseFromString in DOMParser

China☆狼群 提交于 2019-12-06 07:39:47

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/23022956/internet-explorer-11-ie-11-throws-syntax-error-using-parsefromstring-in-dompar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!