Hi Carine,

You can also try something like this. More DOM tree insertion and an
extra <g> element.

<?xml version="1.0" ?>
<svg id="root" xmlns="http://www.w3.org/2000/svg"; width="200"
height="200" >

<script><![CDATA[
function charge(evt){
  addrect (evt.target);
}

function addrect (otarget) {
  var oparent = otarget.parentNode;
  var orect = document.createElementNS (
"http://www.w3.org/2000/svg","rect";);
  orect.setAttributeNS(null,"width","50");
  orect.setAttributeNS(null,"height","50");
  orect.setAttributeNS(null,"x","150");
  orect.setAttributeNS(null,"y","100");
  orect.setAttributeNS(null,"fill","#00FF33");
  oparent.appendChild (orect);
  return (orect);
}
]]>
</script>
<g>
  <rect x="10" y="10" width="50" height="50" fill="red"
onclick="charge(evt)"/>
</g>  
</svg>

John
--- In [email protected], carine kouejou <[EMAIL PROTECTED]>
wrote:
> i try to do this operation, i use firefox natif svg:
> 
> That is the code svg i try to execute:
> 
> <?xml version="1.0" ?>
> <svg id="root" xmlns="http://www.w3.org/2000/svg";
> width="200" height="200" >
> 
> <script><![CDATA[
>     function charge(evt){
>       alert("charge");
>       svg=evt.target.ownerDocument;
>       svgRoot=svg.getElementById("root");
>       node=parseXML(svg);
>       svgRoot.appendChild(node);
>     }
>     function  parseXML (doc) {
>       doc2=(new DOMParser()).parseFromString("<rect
> x='100' y='100' width='50'   
>           height='50' fill='green' />","text/xml");
>       doc.importNode(doc2,true);
>       return doc2;
>     
>    }
> ]]>
> </script>
> <rect x="10" y="10" width="50" height="50" fill="red" 
> onclick="charge(evt)"/>
> </svg>
> 
> I have all time that Error: uncaught exception:
> [Exception... "Node cannot be
> inserted at the specified point in the hierarchy" 
> code: "3" nsresult:
> "0x80530003 (NS_ERROR_DOM_HIERARCHY_REQUEST_ERR)" 
> location:
> "file:///C:/Documents%20and%20Settings/alkante/Bureau/Essai.svg
> Line: 10"].
> 
> Please cant you help me.
> 
> how can i use the function parseXML for appendChild
> the node
> thanks
> 
> Carine TCHOKOTE KOUEJOU
> 
> 19 rue du nivernais
> 35000 Rennes
> 
> Tél: 0033627066238
> 
> 
>       
> 
>       
>               
>
___________________________________________________________________________

> Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo!
Messenger 
> Téléchargez cette version sur http://fr.messenger.yahoo.com
> 
> [Non-text portions of this message have been removed]




-----
To unsubscribe send a message to: [EMAIL PROTECTED]
-or-
visit http://groups.yahoo.com/group/svg-developers and click "edit my 
membership"
---- 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/svg-developers/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to