Chrome未显示SVG文件

时间:2022-08-24 18:11:55

I have a SVG ilustration embeded in an HTML5 file which works in all modern browsers when I try it on local, but when I try to serve them from the web I dont get Chrome to render the SVG image, it only renders the SVG source code. I already added this lines to an .htaccess file which solved the issues in Safari and Firefox:

我在一个HTML5文件中嵌入了SVG ilustration,当我在本地尝试时,它可以在所有现代浏览器中运行,但是当我尝试从网络上提供它时,我没有让Chrome渲染SVG图像,它只渲染SVG源代码。我已经将这些行添加到.htaccess文件中,该文件解决了Safari和Firefox中的问题:

AddType image/svg+xml svg
AddType image/svg+xml svgz
AddEncoding x-gzip .svgz

But Chrome now is the only browser that doesn't render the image when comes from the web. My local file works fine even in Chrome.

但Chrome现在是唯一一款在网络上无法呈现图片的浏览器。我的本地文件即使在Chrome中也能正常运行。

What am I missing?

我错过了什么?

Here is the link to the sample of the issue, try it on Safari and Firefox, it will work. But in Chrome the story is different.

这是问题示例的链接,在Safari和Firefox上试用,它会起作用。但在Chrome中,故事情况则有所不同。

EDIT: Link was broken and seems to be missing www. prefix: http://www.getformgallery.com/demo/gos-form.html

编辑:链接被打破,似乎缺少www。前缀:http://www.getformgallery.com/demo/gos-form.html

5 个解决方案

#1


3  

I have the same problem. Before some Chrome updates the svg I used in my site works but from certain Chrome updates those svg didn't worked and the page won't load either, just loads for 1-2s and then redirected to Aw, snap.

我也有同样的问题。在某些Chrome更新之前,我在我网站上使用的svg有效,但是从某些Chrome更新中,这些svg无效,页面也不会加载,只需加载1-2秒然后重定向到Aw,快照。

Finally I figure it out. You have to define "width" and "height" in Object tag eg.

最后我明白了。你必须在Object标签中定义“width”和“height”,例如。

<object height="100%" width="100%"data="images/image.svg" type="image/svg+xml"></object>

#2


1  

Did you export the SVG from Photoshop using an extension like SVG Hero? If so, did you export a smart object? I had the same problem, but fixed it by saving the SVG from Illustrator instead. Now my SVG works in all browsers.

您是否使用SVG Hero等扩展程序从Photoshop导出SVG?如果是这样,你导出了一个智能对象吗?我有同样的问题,但通过从Illustrator中保存SVG来修复它。现在我的SVG适用于所有浏览器。

#3


-1  

I am using Google Chrome 18 and the sample-page renders fine for me, even after going to the SVG image directly. The problem might be solved by the browser-makers.

我正在使用Google Chrome 18,即使直接转到SVG图像,样本页也可以呈现给我。这个问题可能会被浏览器制造商解决。

#4


-2  

Chrome, Firefox, Opera, Safari and all other modern browsers (with the exception of IE) support SVG natively without the need for plugins. so you get plugin First and try do access

Chrome,Firefox,Opera,Safari和所有其他现代浏览器(IE除外)本身支持SVG,无需插件。所以你得到插件首先尝试访问

#5


-2  

SVG files are supported in chrome but are not supported fully. You might have some issue sometimes. Try this link to get help to your answer.

chrome支持SVG文件,但不完全支持。你有时可能会遇到一些问题。尝试此链接以获得您的答案的帮助。

http://upload.wikimedia.org/wikipedia/commons/f/f6/Western_Australia_Local_Government_Areas.svg

http://upload.wikimedia.org/wikipedia/commons/f/f6/Western_Australia_Local_Government_Areas.svg

#1


3  

I have the same problem. Before some Chrome updates the svg I used in my site works but from certain Chrome updates those svg didn't worked and the page won't load either, just loads for 1-2s and then redirected to Aw, snap.

我也有同样的问题。在某些Chrome更新之前,我在我网站上使用的svg有效,但是从某些Chrome更新中,这些svg无效,页面也不会加载,只需加载1-2秒然后重定向到Aw,快照。

Finally I figure it out. You have to define "width" and "height" in Object tag eg.

最后我明白了。你必须在Object标签中定义“width”和“height”,例如。

<object height="100%" width="100%"data="images/image.svg" type="image/svg+xml"></object>

#2


1  

Did you export the SVG from Photoshop using an extension like SVG Hero? If so, did you export a smart object? I had the same problem, but fixed it by saving the SVG from Illustrator instead. Now my SVG works in all browsers.

您是否使用SVG Hero等扩展程序从Photoshop导出SVG?如果是这样,你导出了一个智能对象吗?我有同样的问题,但通过从Illustrator中保存SVG来修复它。现在我的SVG适用于所有浏览器。

#3


-1  

I am using Google Chrome 18 and the sample-page renders fine for me, even after going to the SVG image directly. The problem might be solved by the browser-makers.

我正在使用Google Chrome 18,即使直接转到SVG图像,样本页也可以呈现给我。这个问题可能会被浏览器制造商解决。

#4


-2  

Chrome, Firefox, Opera, Safari and all other modern browsers (with the exception of IE) support SVG natively without the need for plugins. so you get plugin First and try do access

Chrome,Firefox,Opera,Safari和所有其他现代浏览器(IE除外)本身支持SVG,无需插件。所以你得到插件首先尝试访问

#5


-2  

SVG files are supported in chrome but are not supported fully. You might have some issue sometimes. Try this link to get help to your answer.

chrome支持SVG文件,但不完全支持。你有时可能会遇到一些问题。尝试此链接以获得您的答案的帮助。

http://upload.wikimedia.org/wikipedia/commons/f/f6/Western_Australia_Local_Government_Areas.svg

http://upload.wikimedia.org/wikipedia/commons/f/f6/Western_Australia_Local_Government_Areas.svg