以文本方式查看主题 - 中文XML论坛 - 专业的XML技术讨论区 (http://bbs.xml.org.cn/index.asp) -- 『 SVG/GML/VRML/X3D/XAML 』 (http://bbs.xml.org.cn/list.asp?boardid=21) ---- 如何动态的创建<use>元素! (http://bbs.xml.org.cn/dispbbs.asp?boardid=21&rootid=&id=33791) |
-- 作者:tamefox -- 发布时间:6/4/2006 4:48:00 PM -- 如何动态的创建<use>元素! 为什么在svg中直接写use元素,即<use xlink:href="#checkBoxCross" x="100" y="100"/> 好用,而通过js采用如下语句添加use元素不好用呢 var node=document.createElement("use"); node.setAttribute("xlink:href","#checkBoxRect"); node.setAttribute("x",160) node.setAttribute("y",160) document.getElementById("aa").appendChild(node); 用alert(printNode(document.getElementById("aa")))显示该元素存在,但是就是不好用,不显示 |
-- 作者:DragonJohn -- 发布时间:6/4/2006 5:07:00 PM -- node.setAttributeNS("xlink:href","#checkBoxRect"); |
-- 作者:tamefox -- 发布时间:6/4/2006 8:33:00 PM -- 不行,再说node.setAttributeNS("xlink:href","#checkBoxRect");语句本身就有问题,少一个参数。我写成node.setAttributeNS(null,"xlink:href","#checkBoxCross");还是不好用 |
-- 作者:DragonJohn -- 发布时间:6/4/2006 9:39:00 PM -- sorry, node.setAttributeNS(xlinkns,'xlink:href','#checkBoxRect); |
-- 作者:tamefox -- 发布时间:6/5/2006 7:55:00 AM -- 好用了耶,真的很开心。不过再问一下。你的xlinkns是怎么定义的,是在js中定义一个变量xlinkns = "http://www.w3.org/1999/xlink";(我采用的是这种方法),还是别的什么方法。望赐教! |
W 3 C h i n a ( since 2003 ) 旗 下 站 点 苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》 |
46.875ms |