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. Advertisements

  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. Advertisements

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:
    681
    Arne Nordmann
    Jun 28, 2004
  2. Xiangliang Meng
    Replies:
    1
    Views:
    1,899
    Victor Bazarov
    Jun 21, 2004
  3. Mardagg
    Replies:
    0
    Views:
    989
    Mardagg
    May 12, 2006
  4. Mardagg
    Replies:
    0
    Views:
    843
    Mardagg
    May 12, 2006
  5. RC
    Replies:
    1
    Views:
    1,723
    Martin Honnen
    Jun 14, 2006
  6. milof83

    svg to svg saving problem

    milof83, Aug 18, 2006, in forum: Java
    Replies:
    1
    Views:
    1,140
    Roland de Ruiter
    Aug 18, 2006
  7. dhtml
    Replies:
    32
    Views:
    671
    Peter Michaux
    Oct 13, 2008
  8. Dmitry A. Soshnikov

    Note 1. ECMAScript. Bound functions.

    Dmitry A. Soshnikov, Jun 13, 2010, in forum: Javascript
    Replies:
    36
    Views:
    462
    John G Harris
    Jun 24, 2010
Loading...