Re: gteElementById for animate?

HelderMagalhaes <[email protected]> Wed, 3 Feb 2010 02:34:59 -0800 (PST)
Newsgroups gmane.comp.mozilla.devel.svg
Organization http://groups.google.com
Message-ID <5d9b02aa-2eae-457f-a48c-21eeb993fa59@s12g2000yqj.googlegroups.com>
Hi jjb,


> I put this line in my svg doc
> <animate id="migrationAnimateX" attributeName="x2" from="1" to="80"
> dur="2s"/>
> Then I tried Javascript:
>
> doc.getElementById("migrationAnimateX").setAttribute('to', x2);
>
> But I get null from the getElementById?  Just before this code I used
> getElementById() to find a line element. Any idea why I can't get the
> animate element?

I guess Daniel Holbert already gave the pin-point response. :-)

I'd just like to add that, for versions of Firefox without SMIL (or
with it disabled), you can simulate most features using FakeSmile [1],
a JavaScript shim. You can then do something like:

  var target = document.getElementById("YourElementIdGoesHere");
  if(target == null){
    // workaround a gecko bug
    target = id2anim[arguments[i]];
  }


> Thanks,
> jjb

Hope this helps,
 Helder


[1] http://leunen.d.free.fr/fakesmile/