专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > .NET分析设计

appendChild加不进去,该怎么处理

发布时间:2011-06-23 20:39:56 文章来源:www.iduyao.cn 采编人员:星星草
appendChild加不进去
test.svg:—————————————————————————————————————— 
<?xml version="1.0" encoding="utf-8"?> 
<svg width="100%" height="100%" xmlns:xlink="http://www.w3.org/1999/xlink"> 
 <rect id="backRect" x="0" y="60" width="720" height="450" fill="white" stroke="gray" stroke-width="1"/> 
 <circle cx="167" cy="238" r="136" stroke="red" stroke-width="1" fill="blue"/> 
 <rect x="400" y="214" width="56" height="53" stroke="red" stroke-width="1" fill="blue"/> 
 <line x1="397" y1="336" x2="586" y2="353" stroke="red" stroke-width="2"/> 
</svg> 
———————————————————————————————————————————— 

<svg ...> 
... 
//js: 
//方法一: 
function openFile(){ 
xmlDoc = getURL('test.svg',fn); 

function fn(xmlDoc) 

  var x = parseXML(xmlDoc.content); 
  nodeList=x.firstChild.childNodes;  
  for(i=0;i <nodeList.length;i++) 
  { 
var node=nodeList.item(i); 
if(node.nodeType==1){ 
alert(node); 
alert(node.nodeName); 
document.getElementById( "plat").appendChild(node); //产生"wrong document " 错误,IE6 



//方法二: 
function openFile(){ 
xmlDoc = getURL('test.svg',fn); 

function fn(xmlDoc) 

  var x = parseXML(xmlDoc.content, document); //x为object fragdocument类型。 
document.getElementById( "plat").appendChild(x); //没看到效果,alert(x.firstChild)为空! 

... 

<g id="plat" onmousedown="startDraw(evt)" onmousemove="modifyDraw(evt)" onmouseup="endDraw()"> 
<rect id="backRect" x="0" y="60" width="720" height="450" fill="white" 
  stroke="gray" stroke-width="1"/> 
</g> 
</svg> 

想实现的效果就是将test.svg里的rect、circle、line等加到g id=plat中去(和rect id="backRect" 平行),可是看不到效果。 
方法一为什么不行啊?"wrong document " 错误是什么意思呢?方法二中用alert(x.firstChild)为什么为空啊?alert(xmlDoc.content)显 

示的是test.svg的内容,object fragdocument类型该怎么操作啊? 

和http://topic.csdn.net/u/20070912/18/778b8974-5b16-4759-a003-57fe73554aac.html上遇到的情况差不多。可是还是不懂,请赐教。 


------解决方案--------------------
呵呵 已放到web开发板块了。。
------解决方案--------------------
请问在aspx 中通过 embed 调用svg 怎么添加svg节点 并显示出来 我添加了但页面中svg图像没有变化
http://topic.csdn.net/u/20090503/11/6867d960-7820-4a5c-9abe-84b1975fc48c.html
------解决方案--------------------
up
------解决方案--------------------
up
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: