对象在Internet Explorer 10(Windows 8)中不支持属性或方法'transformNode'

编程入门 行业动态 更新时间:2024-10-12 05:55:32
本文介绍了对象在Internet Explorer 10(Windows 8)中不支持属性或方法'transformNode'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我遇到了一些JavaScript问题,这些问题似乎只出现在Windows 8上的Internet Explorer 10中(IE 7、8和9都可以正常工作).我正在做的基本工作是从Web服务获取XML和XSL,然后使用Sys.Net.XMLDOM对象将它们转换为JavaScript以呈现在页面上.

I am having some JavaScript issues that seem to only occur in Internet Explorer 10 on Windows 8 (IE 7, 8, and 9 all work fine). The basic jist of what I am doing is getting XML and XSL from a web service and then transforming them in JavaScript to render on the page using the Sys.Net.XMLDOM object.

XMLDOM = Sys.Net.XMLDOM; var xsl = // XSL gotten from somewhere else var xmlString = // XML gotten from somewhere else as a string... var xml = new XMLDOM(xmlString); var content = xml.transformNode(xsl);

当我在IE 10中使用以上代码时,我得到:

When I use the above code in IE 10, I get:

对象不支持属性或方法"transformNode"

Object doesn't support property or method 'transformNode'

关于Internet Explorer 10为何要这样做的任何想法?

Any ideas on why Internet Explorer 10 is doing this?

编辑

我也尝试过这个:

xmldoc = new ActiveXObject("Msxml2.DOMDocument"); xmldoc.async = false; xmldoc.load(xml); xsldoc = new ActiveXObject("Msxml2.DOMDocument"); xsldoc.async = false; xsldoc.load(xsl); var content = xmldoc.transformNode(xsldoc);

在所有早期版本的IE中都可以使用,但是在IE 10中我得到:

Which works in all previous versions of IE, but in IE 10 I get:

引用未声明的名称空间前缀:"atom".

Reference to undeclared namespace prefix: 'atom'.

推荐答案

找到了答案: blogs.msdn/b/ie/archive/2012/07/19/xmlhttprequest-responsexml-in-ie10-release- Preview.aspx

IE 10要求使用带有responseType设置为"msxml-document"的XMLHttpRequest.将代码切换到该代码后,所有功能都可以在所有浏览器中完美运行:

IE 10 requires using an XMLHttpRequest with the responseType set as "msxml-document". Once I switched the code over to that, everything works perfectly in all browsers:

if (window.XMLHttpRequest) { xhr = new XMLHttpRequest(); } else { xhr = new ActiveXObject("Microsoft.XMLHTTP"); // For IE 6 } xhr.open("GET", url, false); try { xhr.responseType = "msxml-document"; } catch (e) { }; xhr.send();

更多推荐

对象在Internet Explorer 10(Windows 8)中不支持属性或方法'transformNode'

本文发布于:2023-06-11 00:12:14,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/621991.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:中不   属性   对象   方法   Explorer

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!