I believe you need the SVG DTD declaration for getElementById to work reliably.
-----Original Message----- From: mlindeboom [mailto:[EMAIL PROTECTED] Sent: Thursday, May 11, 2006 3:10 PM To: [email protected] Subject: getElementById question 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/getElementById-question-t1603253.html#a4346978 Sent from the Batik - Users forum at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
