Dynamic animation for SVG elements does not work in IE

I am trying to animate SVG elements by dynamically adding DOM elements with jquery. If I add those elements inside <body>, as shown below, its working. Sample work for this http://jsfiddle.net/bZdfH/2/

<svg>
    <script type="text/ecmascript" xlink:href="http://leunen.me/fakesmile/smil.user.js"/>
    <circle cx="60" cy="60" r="20" style="fill: pink; stroke: red;" >
    <animate attributeName="r" dur="4s" values="20; 0; 20" repeatCount="indefinite"/>
    </circle>
 </svg>

When I add it dynamically, the animation does not start in IE, however it works with Chrome and FireFox. Here is what I have.

<svg>
 <script type="text/ecmascript" xlink:href="http://leunen.me/fakesmile/smil.user.js"/>
 <circle cx="60" cy="60" r="20" style="fill: pink; stroke: red;" onmouseover="changeImage(this)" >
 </circle>
</svg>
<script>
    function changeImage(circle) {
      while (circle.firstChild) {
        circle.removeChild(circle.firstChild);
      }
      circle.setAttributeNS(null, "fill", "blue");
        var animate = document.createElementNS("http://www.w3.org/2000/svg", "animate");
        animate.setAttributeNS(null, "attributeName", "r");
        animate.setAttributeNS(null, "values", "20;0;20");
        animate.setAttributeNS(null, "dur", "6s");
        animate.setAttributeNS(null, "repeatCount", "indefinite");
        circle.appendChild(animate);
      }
</script>

Here is jsfiddle for a working sample. Anyone please help me ??

+4
source share
1 answer
+1

All Articles