【问题标题】:Inkscape .HTML SVG file works in Chrome but not in IE9Inkscape .HTML SVG 文件适用于 Chrome,但不适用于 IE9
【发布时间】:2013-10-23 18:15:58
【问题描述】:

我有以下 Inkscape 导出的 SVG:

[TESTSVG.HTML]

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->

<svg
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:cc="http://creativecommons.org/ns#"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:svg="http://www.w3.org/2000/svg"
   xmlns="http://www.w3.org/2000/svg"
   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
   width="744.09448819"
   height="1052.3622047"
   id="svg2"
   version="1.1"
   inkscape:version="0.48.4 r9939"
   sodipodi:docname="mainscreen.svg">
  <defs
     id="defs4" />
  <sodipodi:namedview
     id="base"
     pagecolor="#ffffff"
     bordercolor="#666666"
     borderopacity="1.0"
     inkscape:pageopacity="0.0"
     inkscape:pageshadow="2"
     inkscape:zoom="0.7"
     inkscape:cx="175.99454"
     inkscape:cy="739.86976"
     inkscape:document-units="px"
     inkscape:current-layer="layer1"
     showgrid="false"
     inkscape:window-width="1366"
     inkscape:window-height="706"
     inkscape:window-x="-8"
     inkscape:window-y="-8"
     inkscape:window-maximized="1" />
  <metadata
     id="metadata7">
    <rdf:RDF>
      <cc:Work
         rdf:about="">
        <dc:format>image/svg+xml</dc:format>
        <dc:type
           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
        <dc:title />
      </cc:Work>
    </rdf:RDF>
  </metadata>
  <g
     inkscape:label="Layer 1"
     inkscape:groupmode="layer"
     id="layer1">
    <path
       sodipodi:type="arc"
       style="fill:#ff0000;fill-opacity:1;stroke:#495677;stroke-width:23.16900062999999900;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
       id="circle1"
       sodipodi:cx="227.14285"
       sodipodi:cy="156.6479"
       sodipodi:rx="47.142857"
       sodipodi:ry="44.285713"
       d="m 274.28571,156.6479 a 47.142857,44.285713 0 1 1 -94.28571,0 47.142857,44.285713 0 1 1 94.28571,0 z"
       inkscape:label="#path2985" />
    <rect
       style="fill:#ffff00;fill-opacity:1;stroke:#495677;stroke-width:4.86899999999999980;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
       id="box1"
       width="284.28571"
       height="110"
       x="312.85715"
       y="98.076469"
       inkscape:label="#box1" />
  </g>
</svg>

另存为 HTML 文件 (TESTSVG.HTML),它适用于 Chrome,但不适用于 IE9。如果您将文件名更改为 .SVG (TESTSVG.SVG),它将适用于两种浏览器。

我需要使用 HTML 扩展使其在 IE9 上工作。

感谢任何帮助。

【问题讨论】:

    标签: html google-chrome svg internet-explorer-9


    【解决方案1】:

    您可以像这样添加 HTML DTD 并嵌入 SVG(在 IE10 中有效 - 在 9 中无法测试)应该可以我认为

    <!DOCTYPE html>
    <html>
    <body>
    
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <!-- Created with Inkscape (http://www.inkscape.org/) -->
    
    <svg
       xmlns:dc="http://purl.org/dc/elements/1.1/"
       xmlns:cc="http://creativecommons.org/ns#"
       xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
       xmlns:svg="http://www.w3.org/2000/svg"
       xmlns="http://www.w3.org/2000/svg"
       xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
       xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
       width="744.09448819"
       height="1052.3622047"
       id="svg2"
       version="1.1"
       inkscape:version="0.48.4 r9939"
       sodipodi:docname="mainscreen.svg">
      <defs
         id="defs4" />
      <sodipodi:namedview
         id="base"
         pagecolor="#ffffff"
         bordercolor="#666666"
         borderopacity="1.0"
         inkscape:pageopacity="0.0"
         inkscape:pageshadow="2"
         inkscape:zoom="0.7"
         inkscape:cx="175.99454"
         inkscape:cy="739.86976"
         inkscape:document-units="px"
         inkscape:current-layer="layer1"
         showgrid="false"
         inkscape:window-width="1366"
         inkscape:window-height="706"
         inkscape:window-x="-8"
         inkscape:window-y="-8"
         inkscape:window-maximized="1" />
      <metadata
         id="metadata7">
        <rdf:RDF>
          <cc:Work
             rdf:about="">
            <dc:format>image/svg+xml</dc:format>
            <dc:type
               rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
            <dc:title />
          </cc:Work>
        </rdf:RDF>
      </metadata>
      <g
         inkscape:label="Layer 1"
         inkscape:groupmode="layer"
         id="layer1">
        <path
           sodipodi:type="arc"
           style="fill:#ff0000;fill-opacity:1;stroke:#495677;stroke-
    
    width:23.16900062999999900;stroke-linecap:butt;stroke-
    
    linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-
    
    dasharray:none"
           id="circle1"
           sodipodi:cx="227.14285"
           sodipodi:cy="156.6479"
           sodipodi:rx="47.142857"
           sodipodi:ry="44.285713"
           d="m 274.28571,156.6479 a 47.142857,44.285713 0 1 1 -94.28571,0 
    
    47.142857,44.285713 0 1 1 94.28571,0 z"
           inkscape:label="#path2985" />
        <rect
           style="fill:#ffff00;fill-opacity:1;stroke:#495677;stroke-
    
    width:4.86899999999999980;stroke-linecap:round;stroke-
    
    linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-
    
    dasharray:none"
           id="box1"
           width="284.28571"
           height="110"
           x="312.85715"
           y="98.076469"
           inkscape:label="#box1" />
      </g>
    </svg>
    
    </body>
    </html>
    

    【讨论】:

    • 同样的问题。不适用于 IE9... 仅适用于 Chrome。 IE9 控制台上没有消息...很奇怪。
    • 你试过我的其他答案了吗?
    【解决方案2】:

    如果有两个文件是可以接受的,您可以执行以下操作(在 IE9 中测试)。在这种情况下,您可以将 SVG 保存为 test.svg:

    <?xml version="1.0"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
                          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    
    <object data='test.svg'></object>  
    
    
    
    </body>
    </html>
    

    【讨论】:

      【解决方案3】:

      我刚刚遇到了同样的问题 - 当代码在 HTML 中内联实现时,IE9 拒绝从 InkScape 呈现 svg。

      问题是标签&lt;sodipodi:namedview 以及这里的所有内容,直到结束标签/&gt;

      尝试删除它,我敢打赌 svg 将在 IE9 中调用 HTML 时呈现。

      【讨论】:

        【解决方案4】:

        这是因为 inkscapesodipodi 在 IE9 中无法识别,尤其是对于内联 SVG。这就是为什么他们需要被删除。你可以参考这个链接Simple SVG Display

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2013-02-19
          • 2014-06-21
          • 2013-07-14
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2013-09-30
          • 1970-01-01
          相关资源
          最近更新 更多