Loading ...
Sorry, an error occurred while loading the content.

Javascript DOM

Expand Messages
  • prem_2324
    Good Morning SVG Developers, As we all know to support interactivity we can use SVG and Javascript within a single file I would like to know about the
    Message 1 of 2 , Feb 4, 2007
    • 0 Attachment
      Good Morning SVG Developers,

      As we all know to support interactivity we can use SVG and Javascript
      within a single file

      I would like to know about the following things::

      1) How does an XML parser distinguish between SVG and Javascript

      2) Does Javascript elemnt have a seperate DOM tree and SVG elements
      have a separate DOM tree.

      3) I would like to have a detailed understanding of Javascript +SVG+DOM

      Thanking u for the same

      Pred
    • Andreas Neumann
      SVG + DOM + JS is pretty much the same like HTML + DOM + JS ... usually, Javascript is in a CDATA block. The content of a CDATA block is ignored by the XML
      Message 2 of 2 , Feb 5, 2007
      • 0 Attachment
        SVG + DOM + JS is pretty much the same like HTML + DOM + JS

        > 1) How does an XML parser distinguish between SVG and Javascript

        usually, Javascript is in a CDATA block. The content of a CDATA block
        is ignored by the XML parser. Also the content of the CDATA block
        does not need to be wellformed.

        > 2) Does Javascript elemnt have a seperate DOM tree and SVG elements
        > have a separate DOM tree.

        There is no DOM tree for Javascript. The content of a Javascript
        block is interpreted by an ECMAScript interpreter. Javascript is an
        object oriented language. Once the ECMAScript code is interpreted,
        you can access methods and properties of the objects in use.

        The DOM is a theoretically language independent interface between the
        document tree (XML, HTML or SVG, or something else), however, in
        practice it is optimized for ECMAScript. The DOM provides interfaces
        for ECMAScript to access nodes, create nodes, delete nodes, reorder
        nodes, change attrihbutes of nodes, etc.

        Hope this helps a little bit. There is a small tutorial on the DOM
        and ECMAScript at http://www.carto.net/papers/svg/
        manipulating_svg_with_dom_ecmascript/index.shtml and one for events
        at http://www.carto.net/papers/svg/eventhandling/index.shtml.

        I also found http://phrogz.net/ObjJob/objects.asp?langID=1 useful to
        see all methods and properties of objects in the SVG DOM, including
        inherited ones.

        Andreas
      Your message has been successfully submitted and would be delivered to recipients shortly.