【发布时间】:2015-03-31 21:41:18
【问题描述】:
我正在尝试使用“img”标签引用 SVG 文件:
<img width="200" height="100"
src="test.svg"
onerror="this.onerror = null; alert('error');"
/>
这通常有效,但如果“test.svg”具有嵌入的 .jpg 图像,则该图像不会呈现。这在 Chrome 和 Firefox 中是正确的——IE 确实正确地呈现了图像。奇怪的是,如果我直接在浏览器中加载“test.svg”,那么嵌入的图像会在每个浏览器上正确呈现。
这是一个“test.svg”的例子,说明了我的意思:
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
width="200" height="100">
<!-- Text and shapes always render correctly -->
<text x="20" y="20" font-size="20">some text</text>
<ellipse ry="30" rx="30"
cy="50" cx="50"
stroke-width="5" stroke="#000000"
fill="#FF0000"
/>
<!-- Embedded images render in IE, but not in Chrome or Firefox -->
<image xlink:href="test.jpg"
width="100" height="100"
x="100" />
</svg>
我还没有找到明确的答案。这是 Webkit 中的错误吗?
【问题讨论】:
标签: html google-chrome svg webkit