0

You can pause an SVG using document.getElementById("mysvg").pauseAnimations(). However that only seems to work for inline SVGs.

Is there any way to pause an SVG animation that is included using <img src="my.svg"/>?

Timmmm
  • 88,195
  • 71
  • 364
  • 509

1 Answers1

0

So as Paul LeBeau said you can't do it with an image. You can do it - apparently - using <object>, something like this:

<object id="mysvg" type="image/svg+xml" data="myfile.svg"/>

And then access it through:

mysvg.contentDocument

That is restricted by the CORS policy which unfortunately means it doesn't work when accessing files via the file:// protocol. In my case (Doxygen) I needed that so I just gave up an included the SVG inline using Doxygen itself like this:

\htmlinclude "myfile.svg"
Timmmm
  • 88,195
  • 71
  • 364
  • 509