getElementById not implemented?

D

danrumney

Hi all,

I'm having some problems understanding why I'm getting an error with
the following SVG document:
http://www.danrumney.co.uk/test.svg

The javascript is pretty basic, call "getElementById" method of an
SVGSVGElement object in order to get a child element of it with a
specified ID... instead I see

Error: uncaught exception: [Exception... "Component returned failure
code: 0x80004001 (NS_ERROR_NOT_IMPLEMENTED)
[nsIDOMSVGSVGElement.getElementById]" nsresult: "0x80004001
(NS_ERROR_NOT_IMPLEMENTED)" location: "JS frame ::
http://www.danrumney.co.uk/demo.js :: <TOP_LEVEL> :: line 4" data: no]

In the Javascript console.

I'm using Firefox 1.5.0.8. The SVG *is* rendering, so I know that the
SVG is fine. Also, the javascript is simple enough that, by inspection,
it all looks fine.

What I'm thinking is that, perhaps a different Javascript interpreter
is used for SVG as compared to the one for HTML. Not sure *why* this
would be the case, but I can't think of an alternative reason.

Any suggestions/guidance would be appreciated.

Dan
 
M

Martin Honnen

I'm having some problems understanding why I'm getting an error with
the following SVG document:
http://www.danrumney.co.uk/test.svg

The javascript is pretty basic, call "getElementById" method of an
SVGSVGElement object in order to get a child element of it with a
specified ID... instead I see

Error: uncaught exception: [Exception... "Component returned failure
code: 0x80004001 (NS_ERROR_NOT_IMPLEMENTED)
[nsIDOMSVGSVGElement.getElementById]" nsresult: "0x80004001
(NS_ERROR_NOT_IMPLEMENTED)" location: "JS frame ::
http://www.danrumney.co.uk/demo.js :: <TOP_LEVEL> :: line 4" data: no]

You need to call getElementById on the document object, not on an element.
 
M

Martin Honnen

While it may not be *the* reference,
http://www.xulplanet.com/references/objref/SVGSVGElement.html,
indicates that getElementById is a method of the SVGSVGElement.

However, the change you recommended did work.

However, does that mean, then, that you cannot call "getElementById" on
arbitrary SVGElements?

The Core DOM W3C specification defines a method getElementById on the
document object. As ids have to be unique inside the document that
method suffices.
SVG seems to additionally define a method getElementById on
SVGSVGElement (<http://www.w3.org/TR/SVG11/ecmascript-binding.html>) but
it does not look as if that method is implemented in Mozilla so far
<https://bugzilla.mozilla.org/show_bug.cgi?id=280391>
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,120
Latest member
ShelaWalli
Top