发布到网页后,SVG不会在对象标签中显示 [英] SVG not showing in object tag after publishing to web

查看:476
本文介绍了发布到网页后,SVG不会在对象标签中显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用MS Visual Web Developer 2010 Express在调试模式下运行时,我能够使用object标记(img标记不起作用,也没有background-image属性)显示SVG文件。我的浏览器是IE11。但是,在发布到网络后,SVG文件不会显示,并且在显示时会显示alt内容。即使在发布到web之后,img标签也不会与SVG一起使用,并且svg标签始终可用。我只需要让对象标记起作用,然后将其他信息作为附加信息用于确定可能发生的事情。

I am able to get the SVG files to display using the object tag (img tag didn't work nor did background-image property) while running in debug mode using MS Visual Web Developer 2010 Express. My browser is IE11. But after publishing to the web, the SVG files do not show and will display the "alt" content when included. The img tag never works with SVG and the svg tag always works, even after being published to web. I only need to get the object tag to work however, and just included the others as additional information for figuring out what might be going on.

    <body>
        <form id="form1">
            <img alt="image missing" src="Images/circle.svg" />
            <object data="Images/circle.svg" type="image/svg+xml">object missing</object>
            <svg>
                <circle cx="50" cy="50" r="40" stroke="green" stroke-width="4" fill="yellow" />
            </svg>
        </form>
    </body>

当我用png替换svg文件时,所有三个图像都显示在调试以及之后发布到网络上。 png和svg文件保存在同一个文件夹中。我尝试了另一个浏览器(Chrome),结果相同。任何想法,为什么svg不会显示?谢谢。

When I replace the svg file with a png, then all three images display in debug as well as after publishing to the web. The png and svg files are kept in the same folder. I tried another browser (Chrome) with the same results. Any ideas as to why the svg wouldn't display? Thanks.

推荐答案

我解决了这个问题。我不得不将.svg mime类型添加到应用程序的web.config文件中。以下代码已添加到web.config中,现在所有可缩放矢量图形都显示在调试中的图像标签和对象标签中,以及已发布的图像中。

I resolved the issue. I had to add the .svg mime type to the application's web.config file. The following code was added to web.config and now all scalable vector graphics display in both the image tag and object tag in debug as well as released.

    <configuration>
       <system.webServer>
          <staticContent>
             <mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
          </staticContent>
       </system.webServer>
    </configuration>

我在这里找到了解决方案:
https://serverfault.com/questions/359904/how-to-configure-iis -for-svg-and-web-testing-with-visual-studio

I found the solution here: https://serverfault.com/questions/359904/how-to-configure-iis-for-svg-and-web-testing-with-visual-studio

在这里: http://www.codeproject.com/Tips/439273/Viewing-SVG-and-其他-HTML5-content-when-debugging

这篇关于发布到网页后,SVG不会在对象标签中显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆