When I load the following svg file I get an error. It seems that if a group
or other element  is created using code, the getElementById() function
cannot find it later. Is this true or is there something else wrong with the
script?

<svg  width="500" height="500" onload="main(evt)">
<script><![CDATA[
function main(evt){
  var svgdoc = evt.target.ownerDocument;
  var root = svgdoc.firstChild;
  var rootnode = svgdoc.getElementById('root')
  buildgroups(svgdoc,'xx');
  buildLabel(svgdoc,'xx');

}
function buildgroups(mydoc, prefix){
  var root = mydoc.getElementById('root');
  //p1
  var node = mydoc.createElement('g');
  node.setAttribute('id',prefix + 'p1');
  root.appendChild(node);
}
function buildLabel(mydoc, prefix){
  var xxp1 = mydoc.getElementById(prefix + 'p1');
  var node = xxp1.createElement('text');
  xxp1.appendChild(node);       
}
]]></script>
<g id='root'> </g>
</svg>

--
View this message in context: 
http://www.nabble.com/Problem-with-getElementById--t1600327.html#a4339555
Sent from the Batik - Dev forum at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to