Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
62 lines (49 sloc) 1.96 KB
<embed src="circle.svg" width="50" height="50" type="image/svg+xml" />
<div id="a1"></div>
<script>
var svgns = "http://www.w3.org/2000/svg";
// first make an svg object
var s1 = document.createElementNS(svgns, 'svg');
s1.setAttribute("width", 200);
s1.setAttribute("height", 100);
s1.setAttribute("style","background-color:grey");
document.getElementById("a1").appendChild(s1);
var shape = document.createElementNS(svgns, "circle");
shape.setAttributeNS(null, "cx", 25);
shape.setAttributeNS(null, "cy", 25);
shape.setAttributeNS(null, "r", 20);
shape.setAttributeNS(null, "fill", "green");
s1.appendChild(shape);
</script>
The Origional code was
<pre>
&lt;embed src="circle.svg" width="50" height="50" type="image/svg+xml" />
&lt;?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
&lt;!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd" [
&lt;!ATTLIST svg
xmlns:a3 CDATA #IMPLIED
a3:scriptImplementation CDATA #IMPLIED>
&lt;!ATTLIST script
a3:scriptImplementation CDATA #IMPLIED>
]>
&lt;svg onload="makeShape(evt)"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:a3="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/"
a3:scriptImplementation="Adobe">
&lt;script type="text/ecmascript" a3:scriptImplementation="Adobe">&lt;![CDATA[
var svgns = "http://www.w3.org/2000/svg";
function makeShape(evt) {
if ( window.svgDocument == null )
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");
svgDocument.documentElement.appendChild(shape);
}
]]>&lt;/script>
&lt;/svg>
</pre>