How dynamically add flash-object to html in IE 11?

926 views Asked by At

I saw Adobe recommendation, but there was static html-code for embed. I try use dynamically by JS, but strange thing. flash-player was embed into page. But swf-movie - not. I think something wrong with name parametr. But can't guess how need do right.

static (working)

object type="application/x-shockwave-flash" data="menu.swf" width="1200" height="300">
    <param name="movie" value="menu.swf"/>
</object>

dynamically (not working)

var node=document.createElement('object');
    document.body.appendChild(node);

    node.type="application/x-shockwave-flash"
    node.data="menu.swf"
    //node.name="menu.swf"

    node.width="300"
    node.height="300"

    var p=document.createElement('param');


    p.name="movie"
    p.value="menu.swf"
    node.appendChild(p)

I tried make many combinations, but nothing working

This problem strongly for IE11. For other versions IE working next code:

var node=document.createElement('object');
    document.body.appendChild(node);

    node.classid= "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
    node.movie="menu.swf"
        ... 
1

There are 1 answers

0
user5555232 On BEST ANSWER

There was 2 mistakes in my code.

Main feature - the addition object to DOM must be AFTER ASSEMBLY of the object:

var node=document.createElement('object');
node.type="application/x-shockwave-flash"
node.data="menu.swf"        
node.width="300"
node.height="300"
document.body.appendChild(node); // must be in end

or

var node=document.createElement('object');
node.setAttribute('type',"application/x-shockwave-flash")
node.setAttribute('data',"menu.swf")
node.setAttribute('width',"300")
node.setAttribute('height',"300")
document.body.appendChild(node); // must be in end

Next feature - there was tag in html head:

<meta http-equiv="X-UA-Compatible" content="IE=9">

If IE11 find X-UA-Compatible less then 11/edge, there is need old style embed flash (classid). If there is not X-UA-Compatible or value is 11/edge - then need new style as type="application/x-shockwave-flash" in html