Hi. mlindeboom: > 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?
There are other problems with the document, which may or may not be related: > <svg width="500" height="500" onload="main(evt)"> This should have the SVG namespace declaration: <svg xmlns=”http://www.w3.org/2000/svg” …> > <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'); var node = mydoc.createElementNS("http://www.w3.org/2000/svg", "g"); > node.setAttribute('id',prefix + 'p1'); Should be: node.setAttributeNS('id', prefix + 'p1'); but in Batik this will be OK, perhaps not in other UAs. > root.appendChild(node); > } > function buildLabel(mydoc, prefix){ > var xxp1 = mydoc.getElementById(prefix + 'p1'); > var node = xxp1.createElement('text'); var node = xxp1.createElementNS("http://www.w3.org/2000/svg", "text"); > xxp1.appendChild(node); > } > ]]></script> > <g id='root'> </g> > </svg> With these changes do you still have the problem? -- Cameron McCormack ICQ: 26955922 cam (at) mcc.id.au MSN: cam (at) mcc.id.au http://mcc.id.au/ JBR: heycam (at) jabber.org --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
