Testing in Firefox 3.0.1 showed that using 'xml:id' does not work. But Firefox implements a Javascript function to evaluate XPath expressions, so I figured it would be possible to find the element this way. Here's the code for a function which works with both 'id' and 'xml:id' in Firefox, and will work in all browsers in which getElementById() gives a result:
function myGetElementById(id) { var element = document.getElementById(id); if(element==null && document.evaluate!=null) { element = document.evaluate( '//[EMAIL PROTECTED]:id="' + id + '" or @id="' + id + '"]', document, function(ns) { switch(ns) { case "xml": return "http://www.w3.org/XML/1998/namespace"; case null: return null; } }, XPathResult.ANY_TYPE, null ).iterateNext(); } return element; } --- In svg-developers@yahoogroups.com, Erik Dahlström <[EMAIL PROTECTED]> wrote: > > The elements are part of the DOM tree, since it's XML, but the 'id' attribute is not of type ID for arbitrary XML. You could use 'xml:id' in such cases, but I'm not sure FF supports that. The other option is to push for FF to recognize the elements as SVG elements. > > Cheers > /Erik > > On Thu, 30 Oct 2008 16:44:49 +0100, Klaus Förster <[EMAIL PROTECTED]> wrote: > > > Olaf, could it be that this is due to missing animation support in FF3. > > It seems that unknown elements are discarded and thus not part of the > > DOM tree ... > > > > Klaus > > > > Olaf Schnabel wrote: > >> > >> > >> Hi developers > >> > >> I currently try to detect an animation element in a SVG file with > >> document.getElementById(). Unfortunately, Firefox 3.0.3 returns always > >> "null". In Opera 9.62 and IE7+ASV3.03 this example works well (I am > >> working on Windows XP SP3). Has somebody an idea how this can be? I > >> thought that getElementById() is implemented in all major browsers??? > >> > >> Here is the link to the example: > >> http://www.ika.ethz.ch/schnabel/getelementbyid_firefoxbug.svg > >> <http://www.ika.ethz.ch/schnabel/getelementbyid_firefoxbug.svg> > >> > >> Thanks for your help. > >> Regards > >> Olaf > >> > >> -- > >> Dr. Olaf Schnabel > >> Institute of Cartography > >> ETH Zurich > >> Wolfgang-Pauli-Str. 15 > >> 8093 Zurich > >> Switzerland > >> > >> tel: ++41 44 633 3031 > >> fax: ++41 44 633 1153 > >> e-mail: [EMAIL PROTECTED] <mailto:oschnabel%40ethz.ch> > >> www private: http://www.ika.ethz.ch/schnabel > >> <http://www.ika.ethz.ch/schnabel> > >> www project: http://www.e-cartouche.ch <http://www.e- cartouche.ch> > >> www institute: http://www.karto.ethz.ch <http:// www.karto.ethz.ch> > >> > >> > > > > > > -- > Erik Dahlstrom, Core Technology Developer, Opera Software > Co-Chair, W3C SVG Working Group > Personal blog: http://my.opera.com/macdev_ed > ------------------------------------ ----- To unsubscribe send a message to: [EMAIL PROTECTED] -or- visit http://groups.yahoo.com/group/svg-developers and click "edit my membership" ----Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/svg-developers/ <*> Your email settings: Individual Email | Traditional <*> To change settings online go to: http://groups.yahoo.com/group/svg-developers/join (Yahoo! ID required) <*> To change settings via email: mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/