以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 SVG/GML/VRML/X3D/XAML 』  (http://bbs.xml.org.cn/list.asp?boardid=21)
----  [求助] 点击按钮,生成svg图像。。。高手,帮我  (http://bbs.xml.org.cn/dispbbs.asp?boardid=21&rootid=&id=79251)


--  作者:gj1989816
--  发布时间:12/23/2009 10:44:00 AM

--  [求助] 点击按钮,生成svg图像。。。高手,帮我
----------------------svg--------------
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-flat-20030114.dtd">
<!-- Created by SVGDeveloper 1.0 -->
<svg id="a" width="400" height="400" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<rect id="Rect" width="400" height="400" fill="white" stroke="black" stroke-width="5">
</rect></svg>


---------------------------html----------------

<html>
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
   <title>Untitled file</title>
  </head>
  <script type="text/javascript">
   var SVGDoc=null;
   var SVGRoot=null;
   
   function init(){
     htmlObj = document.getElementById("text2add");
        SVGDoc = htmlObj.getSVGDocument(); //得到svg的跟节点
        SVGRoot = SVGDoc.documentElement; //得到 document的元素
   }
   
   function add(){
     innerSVG=SVGDoc.getElementById("Rect");
  
     myData = SVGDoc.createTextNode("newText 2 add");
        newText = SVGDoc.createElementNS(svgns, "text");
        newText.setAttributeNS(null, "id", "textid");
        newText.setAttributeNS(null, "x", "55px");
        newText.setAttributeNS(null, "y", "100px");
        newText.setAttributeNS(null, "font-size", "24pt");
        newText.setAttributeNS(null, "stroke", "red");
        newText.appendChild(myData);
        SVGDoc.getElementById("a").appendChild(newText);  
   }
      
</script>
  <body onload="init()">
   <EMBED id="text2add" SRC="Unnamed - 2.svg" width="500" height="450" type="image/svg+xml">
    <input type="button" value="addText" onclick="add()"/>
   </body>
  </html>


--  作者:liang3331
--  发布时间:1/15/2010 11:23:00 PM

--  
为啥论坛里关于svg得 东西那么少呢。。。
W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
42.969ms