Question about some basic functions in SVG ECMAScript

Discussion in 'Javascript' started by RC, Jun 14, 2006.

  1. RC

    RC Guest

    Sorry I couldn't find appropriate group for
    SVG and ECMAScript. Since SVG is in XML format
    and ECMAScript is very similar to JavaScript.
    What's why I post in these two groups.

    In the O'Reilly SVG book, in chapter 11
    Animating and Scripting SVG. It mentions
    some very basic functions like

    var circle = event.getTarget();

    var obj = svgDocument.getElementById("idName");

    I got error message said these are no a function
    in Firefox and batik-squiggle.jar

    When I used SVGView plug-in (made by Adobe) for IE .

    I typed:

    var svgObject = evt.target;
    var svgDoc = svgObject.getOwnerDocument();
    var svgElement = svgDoc.getElementById(idName);
    var svgStyle = svgElement.getStyle();
    svgStyle.setProperty('stroke-width', 3);

    These lines are working fine for SVGViwe Plug-in by
    not work for Firefox and batik.
    They complained that getOwnerDocument is not a function.
    I tried to change getSVGDocument but no luck.

    Is that O'Reilly book too old? Its first editoin is 2002.

    How can I make getElementById() working in Firefox and Batik?
    Is there some examles or some documents?
    Thank Q very much in advance!
    RC, Jun 14, 2006
    #1
    1. Advertising

  2. RC wrote:

    > var circle = event.getTarget();
    >
    > var obj = svgDocument.getElementById("idName");


    > var svgObject = evt.target;
    > var svgDoc = svgObject.getOwnerDocument();
    > var svgElement = svgDoc.getElementById(idName);
    > var svgStyle = svgElement.getStyle();
    > svgStyle.setProperty('stroke-width', 3);


    The ECMAScript binding for the DOM want you to use e.g.
    event.target
    svgObject.ownerDocument
    svgElement.style
    and not those getXXX variants you are using.
    With the Adobe SVG viewer you can use both variants but for newer SVG
    implementations you need the variants I have outlined above.
    See also
    <http://jwatt.org/svg/authoring/#asv-getters-and-setters>
    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Jun 14, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Arne Nordmann
    Replies:
    0
    Views:
    502
    Arne Nordmann
    Jun 28, 2004
  2. Mardagg
    Replies:
    0
    Views:
    789
    Mardagg
    May 12, 2006
  3. Mardagg
    Replies:
    0
    Views:
    638
    Mardagg
    May 12, 2006
  4. RC
    Replies:
    1
    Views:
    1,625
    Martin Honnen
    Jun 14, 2006
  5. dhtml
    Replies:
    32
    Views:
    392
    Peter Michaux
    Oct 13, 2008
Loading...

Share This Page