W3C home > Mailing lists > Public > www-svg@w3.org > May 2000

Adding an SVG object by DOM... help req

From: Scents <scents@ca.freei.net>
Date: Tue, 23 May 2000 09:09:55 -0700
Message-ID: <392AAD53.D6F5F899@ca.freei.net>
To: www-svg@w3.org
I'm trying to figure out how to adjust this code:

                <script>
                        alert("Hello World")
                        if (navigator.appName=="Netscape") {
                                var directTarget = event.getTarget();
                                var svgDocument;
                                if( directTarget.getNodeType() != 9 ) {
                                        // if not DOCUMENT_NODE
                                        svgDocument = directTarget.getOwnerDocument();
                                        } else {
                                        svgDocument = directTarget;
                                        }
                                }
                        var test = svgDocument.createElement('line')
                                test.setAttribute('x1', '-10')
                                test.setAttribute('y1', '-10')
                                test.setAttribute('x2', '10')
                                test.setAttribute('y2', '10')
                                test.setAttribute('style', 'stroke:red;')
                                test.setAttribute('id', 'test')
                                svgDocument.getElementById('graph').appendChild('test')
                        </script>

so it will create a new line in my SVG script.  What do I need to do to
fix this, and get it to write the line correctly?  I'm using NN4.72 w/
Adobe SVG plugin, and I want to write this for both NN and IE.  (The
Netscape-specific code is as provided by Adobe in the ReadMe notes.)

Alex Vincent
Lead Systems Administrator
Scents
San Francisco, CA
Received on Tuesday, 23 May 2000 12:10:08 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 5 November 2012 23:52:47 GMT