Search code examples
javascriptasp.net-mvc-3flashswfobject

SWF doesn't render in IE9 (but does in Chrome/FF)


The following code is NOT rendering a swf from a remote webpage hosted from IIS7 in IE9 but does so in Chrome and FF.

What am I missing?

File: http://srv.ab.com/page/swftestpage.htm

<script type="text/javascript">

        (function () {

            var object = document.createElement('object');
            object.setAttribute('width', '300');
            object.setAttribute('height', '250');
            object.setAttribute('classid', 'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000');

            var param1 = document.createElement('param');
            param1.setAttribute('name', 'movie');
            param1.setAttribute('value', 'http://srv.ab.com/test.swf');

            var embed = document.createElement('embed');
            embed.setAttribute('src', 'http://srv.ab.com/test.swf');
            embed.setAttribute('width', '300');
            embed.setAttribute('height', '250');

            var param2 = document.createElement('param');
            param2.setAttribute('name', 'wmode');
            param2.setAttribute('value', 'transparent');

            object.appendChild(param1);
            object.appendChild(embed);
            object.appendChild(param2);

            var container = document.getElementById('myDivID');
            while (container.firstChild) { container.removeChild(container.firstChild); }
            container.appendChild(object);
        })();

</script>

Solution

  • The correct attribute on the <object> tag is classid. You have clsid

    Reference - http://www.alistapart.com/articles/flashembedcagematch/

    I would seriously just use SWFObject's dynamic publishing instead of re-inventing the wheel here