3

FakeSmileを使用して IE9 で SMIL サポートを偽装しようとしています

SVG 要素を動的に作成し、アニメーション要素を含む rect 要素を追加し、beginElement() を呼び出しています。IE9 でエラーが表示されます: オブジェクトはプロパティまたはメソッド 'beginElement' をサポートしていません

静的 SVG の動作: http://jsfiddle.net/FG3PG/1/

FakeSmile を使用して修正するにはどうすればよいですか? 以下は、私がやろうとしていることを示しています: http://jsfiddle.net/DgMDV/13/

そして、ここに同じコードがあります:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE HTML><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <script type="text/javascript" src="http://bazaar.launchpad.net/~smilteam/smil/MAIN/download/head:/smil.user.js-20080305202719-59ane0zgfr5f3vz8-1/smil.user.js"></script>
</head>
<body>
<meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8" />
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" height="200">
   <rect class="drag resize" x="10" y="10" width="100" height="50" fill="#c66" />
</svg>
<script type="text/javascript">
    var svg   = document.getElementsByTagName('svg')[0];
    var svgNS = svg.getAttribute('xmlns');
    var rect = document.getElementsByTagName('rect')[0];

    var animation = document.createElementNS(
        "http://www.w3.org/2000/svg", "animate");
    animation.setAttributeNS(null, 'attributeName', 'x');
    animation.setAttributeNS(null, 'dur', 0.5);
    animation.setAttributeNS(null, 'begin', 'indefinite');
    animation.setAttributeNS(null, 'fill', 'freeze');
    animation.setAttributeNS(null, 'to', 100);
    rect.appendChild(animation);
    animation.beginElement();
</script>
</body>
</html>
4

2 に答える 2

0

プロパティを正しく設定していないようです:

animation.setAttributeNS(null, 'begin', 'indefinite');

値に一致するようにプロパティ名を変更します。

animation.setAttributeNS(null, 'repeatCount', 'indefinite');
于 2012-07-13T07:02:34.250 に答える