开发者

Any cross browser solution for SVGs?

I know Raphael.js uses svg, and its totally crossbrowser: it even works on ie6! So I guess there must be some js fix that allows to use svg in every browser, right? I dont need a whole graphics and animation library like Raphael, just SV support in IE and the like.

开发者_如何学编程

I was just reading about SVGweb, in which development Google was involved, but apparently it uses Flash, so its not cross browser safe.


Raphael has a drawing backend for IE, which uses VML DOM, and a backend for SVG-enabled browsers, which uses SVG DOM. It then has a facade which exposes a uniform drawing API, and at runtime, it loads the appropriate backend, which delegates calls to the uniform drawing API to the appropriate browser API (either SVG or VML DOM).

This is a common strategy in js libraries. For example, this strategy is also employed in dojox.gfx. See, here's the SVG adapter: http://svn.dojotoolkit.org/src/dojox/trunk/gfx/svg.js And here's the VML adapter: http://svn.dojotoolkit.org/src/dojox/trunk/gfx/vml.js

Although I haven't tried it myself, another library you might look into is the Ample SDK, which works similarly to SVG Web, in that the developer programs against the regular SVG DOM API, as opposed to a specific API exposed by a JavaScript library. Like SVG Web, to accomplish this, it uses a shadow DOM internally. It is, however, different from SVG Web, in that it does not use Flash, but instead delegates to VML internally in IE.


I used both svgweb and Raphael. I found svgweb has terrible performance when there is a lot of adding and removing elements to/from the DOM ( even with suspendRedraw ). Raphael had incomplete support for the whole SVG spec.

The only solution I found to be completely adequate is to use Google Chrome Frame to support SVG. It's soo seamless and it even patches the buggy javascript!

It works in IE6+ and every other browser that doesn't support SVG natively.

http://code.google.com/chrome/chromeframe/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜