4,816
社区成员
发帖
与我相关
我的任务
分享
<?xml version="1.0" encoding="utf-8"?>
<svg id="svg" width="800" height="600" xmlns="http://www.w3.org/2000/svg">
<script>
<![CDATA[
function createRect(){
var shape = document.createElement("rect");
shape.setAttribute("x", 10);
shape.setAttribute("y", 10);
shape.setAttribute("width", 200);
shape.setAttribute("height", 200);
shape.setAttribute("style", "fill: #eeeeee");
shape.getStyle().setProperty("stroke","red");
shape.getStyle().setProperty("stroke-width","1");
document.getDocumentElement().insertBefore(shape,document.getDocumentElement().firstChild);
}
]]>
</script>
<g id="g5" transform="translate(0 80)">
<text id="txt1" x="16px" y="30px" style="font-size:15" onclick="createRect()">create rect</text>
</g>
</svg>
<?xml version="1.0" encoding="utf-8"?>
<svg id="svg" width="800" height="600" xmlns="http://www.w3.org/2000/svg">
<script language="JavaScript" xlink:href="temp.js" />
<g id="g5" transform="translate(0 80)">
<text id="txt1" x="16px" y="30px" style="font-size:15" onclick="createRect()">create rect</text>
</g>
</svg>
function createRect(){
var shape = document.createElement("rect");
shape.setAttribute("x", 10);
shape.setAttribute("y", 10);
shape.setAttribute("width", 200);
shape.setAttribute("height", 200);
shape.setAttribute("style", "fill: #eeeeee");
shape.getStyle().setProperty("stroke","red");
shape.getStyle().setProperty("stroke-width","1");
document.getDocumentElement().insertBefore(shape,document.getDocumentElement().firstChild);
}