使用Javascript创建SVG图形? [英] Creating SVG graphics using Javascript?

查看:133
本文介绍了使用Javascript创建SVG图形?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用Javascript创建SVG图形?

How can I create SVG graphics using Javascript?

所有的浏览器都支持SVG吗?

Do all browsers support SVG?

推荐答案

查看维基百科上的这个列表,关于它浏览器支持SVG。它还提供了脚注中更多细节的链接。例如,Firefox支持基本的SVG,但目前缺乏大多数动画功能。

Have a look at this list on Wikipedia about which browsers support SVG. It also provides links to more details in the footnotes. Firefox for example supports basic SVG, but at the moment lacks most animation features.

有关如何使用Javascript创建SVG对象的教程可以参见这里

A tutorial about how to create SVG objects using Javascript can be found here:

var svgns = "http://www.w3.org/2000/svg";
var svgDocument = evt.target.ownerDocument;
var shape = svgDocument.createElementNS(svgns, "circle");
shape.setAttributeNS(null, "cx", 25);
shape.setAttributeNS(null, "cy", 25);
shape.setAttributeNS(null, "r",  20);
shape.setAttributeNS(null, "fill", "green"); 

这篇关于使用Javascript创建SVG图形?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆