最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Resource interpreted as Document but transferred with MIME type imagesvg+xml: - Stack Overflow

programmeradmin0浏览0评论

When I have an SVG picture with JavaScript chrome says 'Resource interpreted as Document but transferred with MIME type image/svg+xml'. I can include it with iframe or embed TAG same result. But when I change the mime type to something different the browser cannot render it. So i guess "image/svg+xml" is correct?

SVG

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg version="1.1" baseProfile="full" id="draw" 
xmlns="" xmlns:xlink=""
viewBox="0 0 480 480"> 
<defs>
<style type="text/css">
<![CDATA[
]]>
</style>
</defs>
<rect x="0" y="0" width="480" height="480" rx="0" ry="0" fill="rgb(255, 255, 255)" />

</g>
<script type="text/ecmascript"><![CDATA[
(function () { 

//Some code here

}());
]]>
</script>
</svg>

When I have an SVG picture with JavaScript chrome says 'Resource interpreted as Document but transferred with MIME type image/svg+xml'. I can include it with iframe or embed TAG same result. But when I change the mime type to something different the browser cannot render it. So i guess "image/svg+xml" is correct?

SVG

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg version="1.1" baseProfile="full" id="draw" 
xmlns="http://www.w3/2000/svg" xmlns:xlink="http://www.w3/1999/xlink"
viewBox="0 0 480 480"> 
<defs>
<style type="text/css">
<![CDATA[
]]>
</style>
</defs>
<rect x="0" y="0" width="480" height="480" rx="0" ry="0" fill="rgb(255, 255, 255)" />

</g>
<script type="text/ecmascript"><![CDATA[
(function () { 

//Some code here

}());
]]>
</script>
</svg>
Share Improve this question asked Apr 19, 2013 at 12:43 MatthiasMatthias 1,4364 gold badges28 silver badges60 bronze badges 5
  • 1 How do you "change the mime type"? – MaxArt Commented Apr 19, 2013 at 12:55
  • The server responds for SVGz with: Content-Type: image / svg + xml Content-Encoding: gzip – Matthias Commented Apr 19, 2013 at 13:02
  • I was using embed tag previously (now iframe) then I tried it also with type="image/svg+xml" for the embed tag – Matthias Commented Apr 19, 2013 at 13:03
  • Excuse me again, but is the SVG is displayed anyway what is the problem? – MaxArt Commented Apr 19, 2013 at 13:08
  • 2 The console message in chrome. It is not a real problem. But other developers inspecting your code will always be curious if there could be an issue. – Matthias Commented Apr 19, 2013 at 13:13
Add a ment  | 

2 Answers 2

Reset to default 7

Yes, image/svg+xml is the correct internet media type for SVG content, see IANA.

I had this problem for a long time but it appears application/svg-xml is the correct mime.

Refer to this https://github./w3c/svgwg/issues/266 for more details. The mime/svg-xml may be vulnerable too.

发布评论

评论列表(0)

  1. 暂无评论