以文本方式查看主题

-  计算机科学论坛  (http://bbs.xml.org.cn/index.asp)
--  『 SVG/GML/VRML/X3D/XAML 』  (http://bbs.xml.org.cn/list.asp?boardid=21)
----  请问如何动态创建image?  (http://bbs.xml.org.cn/dispbbs.asp?boardid=21&rootid=&id=36522)


--  作者:vagerent
--  发布时间:8/7/2006 10:03:00 PM

--  请问如何动态创建image?
我的方法
function AddNewPoint()//增加新节点
{
 //alert("in");
 var shape = document.createElement("image");
 shape.setAttribute("id", "test");
 shape.setAttribute("x", 200);
 shape.setAttribute("y", 200);
 shape.setAttribute("width", 40);
 shape.setAttribute("height", 40);
 shape.setAttribute("xlink:href", "FlowN2.gif"); 
 shape.setAttribute("canmove", "true");
 document.documentElement.appendChild(shape);
}
不知为什么创建不了。大家帮忙啊。
--  作者:tamefox
--  发布时间:8/8/2006 8:30:00 AM

--  
参考http://bbs.xml.org.cn/dispbbs.asp?boardID=21&ID=33791
xlinkns = "http://www.w3.org/1999/xlink";
node.setAttributeNS(xlinkns,'xlink:href','FlowN2.gif');
--  作者:vagerent
--  发布时间:8/8/2006 8:49:00 AM

--  
谢谢楼上的前辈,好用了!!!
--  作者:upc2neiep
--  发布时间:8/9/2006 9:22:00 AM

--  
看来以后不能动态添加的 都用setAttributeNS(xlinkns,'xlink:href',。。试试
呵呵,前面那个添加defs也是这样的
W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
31.250ms