jQuery SVG 的加载功能与 IE 8 不兼容

发布于 2024-10-04 21:42:55 字数 594 浏览 0 评论 0原文

我通过 jQuery SVG 插件将 SVG 加载到 HTML 中,如下所示:

<div id="map"></div>

<script type="text/javascript">
  $('#map').svg();
  var svg = $('#map').svg('get');
  svg.load('myimage.svg',{onLoad: function(){ alert('ready'); }});
</script>

这段代码在 Firefox 和 Chrome 中运行良好,但在 IE 中运行不佳(版本 8,未测试其他版本)。插件生成的代码如下所示:

 <div id="map" class="hasSVG">
   <svg version="1.1" x="0.0px" y="0.0px" ... ></svg>
 </div>

那么...我该如何修改代码才能支持 IE?我的限制:我需要内联加载 SVG,以便在 onLoad 回调中立即访问 SVG DOM。

谢谢。

I am loading an SVG into an HTML by means of the jQuery SVG plugin as follows:

<div id="map"></div>

<script type="text/javascript">
  $('#map').svg();
  var svg = $('#map').svg('get');
  svg.load('myimage.svg',{onLoad: function(){ alert('ready'); }});
</script>

This piece of code works well in Firefox and Chrome, but not in IE (version 8, no other version tested). The code generated by the plugin looks like this:

 <div id="map" class="hasSVG">
   <svg version="1.1" x="0.0px" y="0.0px" ... ></svg>
 </div>

So...how do I have to modify my code in order to support IE, too? My constraints: I need to load the SVG inline in order to access the SVG DOM right away in the onLoad callback.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

只涨不跌 2024-10-11 21:42:55

只是为了说明明显的情况:IE8 不支持 svg,因此即使您设法正确加载 SVG 元素,如果没有某种 js shim 或插件,它们仍然无法渲染。您尝试过 SVGWeb 吗?在 svgboilerplate.com 上重新开始有一些帮助。

不过,IE9 或许能够运行该代码,您必须进行测试并查看。

Just to state the obvious: IE8 doesn't support svg, so even if you managed to load the SVG elements correctly they still wouldn't render without some sort of js shim or a plugin. Have you tried SVGWeb? Some help to get started over on svgboilerplate.com.

IE9 might be able to run the code though, you'll have to test and see.

在梵高的星空下 2024-10-11 21:42:55

您可以使用 Adob​​e SVG Viewer 作为 IE 的查看器。那应该不是问题。

在开发人员网站上,示例在 IE 6 到 8 和 FF 的所有版本上运行良好。如果我在我的环境中尝试这个插件的一个小例子(例如通过本地主机(XAMPP)或直接访问文件),它在 Firefox 中工作正常,但不适用于 IE。

You can use the Adobe SVG Viewer as a viewer for IE. That should be not the problem.

On the developer site the examples are working fine over all version of IE 6 to 8 and FF. If I try also a small example of this plugin on my environment (e.g. via localhost (XAMPP) or direct access to the file) it works fine Firefox but not for IE.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文