Source du fichier SVG
<svg width="400" height="200" onload="cree_rectangle(evt)"> <script><![CDATA[ function cree_rectangle(evt) {svgdoc=evt.getTarget().getOwnerDocument(); node=svgdoc.createElement("rect"); node.setAttribute("x","50");node.setAttribute("y","50"); node.setAttribute("width","100");node.setAttribute("height","50"); node.setAttribute("style","fill:red"); ou=svgdoc.getElementById("affiche"); ou.appendChild(node); } ]]></script> <g id="affiche"> </g> </svg>