以文本方式查看主题

-  计算机科学论坛  (http://bbs.xml.org.cn/index.asp)
--  『 SVG/GML/VRML/X3D/XAML 』  (http://bbs.xml.org.cn/list.asp?boardid=21)
----  XHTML内嵌SVG的问题  (http://bbs.xml.org.cn/dispbbs.asp?boardid=21&rootid=&id=67196)


--  作者:Qr
--  发布时间:9/12/2008 9:52:00 AM

--  XHTML内嵌SVG的问题
在XHTML中嵌入如下代码,在IE、FF中正常显示SVG各元素。通过javascript+DOM操作该SVG,如添加一个rect和一个text,在IE、FF中均添加成功,但只有FF中能够显示新增的元素,IE不显示新增的元素,何故&如何做?

XHTML with inline SVG:
<svg:svg id="mysvg" width="200" height="30" onclick="test()">
 <svg:rect x="0" y="0" width="150" height="30" rx="10" ry="10"></svg:rect>
</svg:svg>

javascript:
...
rect.setAttribute("x",5);
rect.setAttribute("y",5);
rect.setAttribute("rx",5);
rect.setAttribute("ry",5);
rect.setAttribute("width",140);
rect.setAttribute("height",20);
rect.setAttribute("style","fill:red");
svg.appendChild(trect);

...
text.setAttribute("x",65);
text.setAttribute("y",19);
text.setAttribute("style","fill:yellow;font-weight:900;");
text.appendChild(document.createTextNode("test"));
svg.appendChild(text);


W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
250.000ms