【问题标题】:Getting error Component returned failure code: 0x80600001 firefox获取错误组件返回失败代码:0x80600001 firefox
【发布时间】:2015-01-15 08:30:03
【问题描述】:

// 我完美地将我的 XML DOM 作为源变量 以前我的页面只支持绝对可以正常工作的 Internet Explorer,但现在还需要支持 firefox 和 chrome 才能完成必要的更改。

开始知道 transformNodeToObject 只适用于 IE,不适用于其他浏览器。在 diff 博客中搜索后才知道需要导入 XSL 样式表并将 transformToDocument 与 firefox n chrome 一起使用。因此添加了相同的内容,可以在 else 块中看到,但出现以下错误:-

组件返回失败代码:0x80600001 [nsIXSLTProcessor.importStylesheet] result.importStylesheet(sortPropertiesXSL);

   <html>
  <head>
  <script>
   var properties_xmlDoc = null;
    function loadProperties() 
    { 
        var oXMLContainer = findObject("propertiesXML");
        var sortPropertiesXSL = findObject("sortPropertiesXSL");

        if (properties_xmlDoc == null) 
        {
            properties_xmlDoc = loadXMLFromString(oXMLContainer.value);   
        }
        //for IE
        if(window.ActiveXObject){
          properties_xmlDoc.transformNodeToObject(sortPropertiesXSL, properties_xmlDoc);
        }
        //for other browser
        else {
          var result = new XSLTProcessor();
          result.importStylesheet(sortPropertiesXSL);
          result = result.transformToDocument(properties_xmlDoc);
        }
        findObject("propValueDiv").innerHTML = findObject("propertyValueString").innerHTML;   
    }   

    function findObject(id) {
            return document.getElementById(id); 
        }   
</script>
</head>
<body onload="loadProperties()">
<div id="propValueDiv" />
<div id="propertyValueString"  style="display:none">
   <textarea name="propertyValue" id="propertyValue"</textarea>
</div>   
</body>
</html>

这是我的 xsl :-

<xml id="sortPropertiesXSL" style="display:none;">
    <xsl:stylesheet  version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:output method="xml" version="1.0" indent="yes" encoding="UTF-8" cdata-section-elements="name description value"/>
      <xsl:template match="properties">
        <xsl:copy>
          <xsl:apply-templates>
             <xsl:sort data-type="text" select="name"/>
          </xsl:apply-templates>
        </xsl:copy>
      </xsl:template>

      <xsl:template match="*">
        <xsl:copy>
          <xsl:apply-templates/>
        </xsl:copy>
      </xsl:template>

    </xsl:stylesheet>
</xml>

有人能告诉我为什么这个问题是由 ff 抛出的,以及如何解决这个问题。 谢谢

【问题讨论】:

    标签: javascript xml firefox xslt cross-browser


    【解决方案1】:

    不要尝试在 HTML 文档中嵌入 XML(XSLT 就是这样)。旧的 IE 版本支持所谓的 XML 数据岛,但其他浏览器从不支持,因此嵌入 HTML 中的 XSLT 代码在 Firefox 中被解析为 HTML 而不是 XML。将 XSLT 放入您使用 XMLHttpRequest 加载的自己的文件中,这样它就会被解析为 XML。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-10-14
      • 2011-09-11
      • 2018-03-22
      • 1970-01-01
      • 1970-01-01
      • 2017-02-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多