MozTW 討論區 https://forum.moztw.org/ |
|
javascript: 在XML中新增文字節點問題 (under FireFox)? https://forum.moztw.org/viewtopic.php?f=18&t=29445 |
第 1 頁 (共 1 頁) |
發表人: | hjchen [ 2010-02-04, 18:51 ] |
文章主題 : | javascript: 在XML中新增文字節點問題 (under FireFox)? |
您好, 希望您能帮帮忙. 以下的程式(addText)可以在IE上正常執行来新增文字節点, 但是在Firefox卻無法成功, 請問是哪出了問題? 該如何改才能在FireFox順利執行?! 谢谢! ------------- <?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.dtd"> <!-- file:unit.svg --> <svg id="svg00" version="1.1" xmlns="http://www.w3.org/2000/svg" > <rect id="rect0001" x="10" y="10" width="600" height="600" fill="white" stroke="black" stroke-width="2" /> <svg id="svg01" x="10" y="10" width="600" height="600" viewBox="0 0 600 600" preserveAspectRatio="none" version="1.1" xmlns="http://www.w3.org/2000/svg" > <g id="g001" transform="scale(1.0)"> <g id="g002" transform="translate(0,0)" fill-opacity="0.01" > <rect id="rect0002" x="100" y="100" width="60" height="60" fill="white" stroke="blue" stroke-width="1" onmousedown="addText()"/> </g> </g> <script type="text/javascript"> <![CDATA[ function addText(){ var GroupID02=document.getElementById("g002"); var textName="text0009"; var newText=document.createElement("text"); newText.setAttribute("id",textName); newText.setAttribute("x",400); newText.setAttribute("y",400); newText.setAttribute("font-size",20); newText.setAttribute("fill","red"); newText.setAttribute("fill-opacity",1); newText.appendChild(document.createTextNode("ABCDEFG")); GroupID02.appendChild(newText); } ]]> </script> </svg> </svg> |
發表人: | BobChao [ 2010-02-06, 06:00 ] |
文章主題 : | Re: javascript: 在XML中新增文字節點問題 (under FireFox)? |
我不太確定這是不是 bug,可能是。 用 Firebug 下去看其實 text node 有生成,只是不在 <rect> 裡,而是跑到他後面去了。先把裡頭那個 <rect /> 改 <rect></rect> 看看?是蟲的話再麻煩你報一下 bugzilla 了,這邊技術我很不熟。 |
發表人: | hjchen [ 2010-02-08, 16:00 ] | ||
文章主題 : | Re: javascript: 在XML中新增文字節點問題 (under FireFox)? | ||
站長, 謝謝你的回覆. 我試過了, 一樣不行. 我已將此問題file至bugZilla. 謝謝!!
|
發表人: | Thinker [ 2010-02-09, 09:02 ] |
文章主題 : | Re: javascript: 在XML中新增文字節點問題 (under FireFox)? |
hjchen 寫: 您好, 希望您能帮帮忙. 以下的程式(addText)可以在IE上正常執行来新增文字節点, 但是在Firefox卻無法成功, 請問是哪出了問題? 該如何改才能在FireFox順利執行?! 谢谢! ------------- <?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.dtd"> <!-- file:unit.svg --> ............. var newText=document.createElement("text"); ....... } ]]> </script> </svg> </svg> 請改用 createElementNS(), 並使用 svg 的 namespace 即可。 |
第 1 頁 (共 1 頁) | 所有顯示的時間為 UTC + 8 小時 |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |