【发布时间】:2019-04-25 00:46:15
【问题描述】:
在 Internet Explorer Edge 的 iFrame 中使用 SVG 时遇到问题:相对路径被转换为绝对路径,以父网站为基础。
这是一个简单的例子:
父网站:
<html>
<body>
<iframe src="./js/index.html" frameborder="0"></iframe>
</body>
</html>
Iframe (js/index.html):
<html>
<body>
<svg>
<use xlink:href="./img1/icons1.svg#icon-view-close"></use>
</svg>
<img src="./img1/image1.jpg" alt="">
</body>
</html>
在网络调试器中,Edge 请求的是“http://localhost:5500/img1/icons1.svg”,而不是请求“http://localhost:5500/js/img1/icons1.svg”。
这个问题似乎只影响 SVG 的使用,因为 JPG 图像的路径被正确解释:“http://localhost:5500/js/img1/image1.jpg”
注意:我尝试将已弃用的 xlink:href 转换为简单的 href,但它并没有改变任何东西。
它在我们测试的所有其他浏览器中都能正常工作:Chrome、FF 甚至 IE 11,因为我们使用 JS 库 https://github.com/Keyamoon/svgxuse
(我在 Windows 10 上使用 Microsoft Edge 41.16299.785.0。)
我非常感谢您对此事的任何意见! 提前感谢您的时间:)
【问题讨论】:
标签: internet-explorer svg iframe