1

我看到了Adob​​e 推荐,但是有用于嵌入的静态 html 代码。我尝试由 JS 动态使用,但很奇怪。flash-player 被嵌入到页面中。但瑞士法郎电影- 不是。我认为名称参数有问题。但无法猜测需要如何做对。

静态(工作)

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

动态(不工作)

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)

我尝试了很多组合,但没有任何效果

这个问题对于 IE11 强烈。对于其他版本的 IE 工作下一个代码:

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

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

1 回答 1

1

我的代码中有 2 个错误。

主要特征- DOM 的添加对象必须在对象的组装之后:

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

或者

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

下一个功能 - html 头中有标签:

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

如果 IE11 发现 X-UA-Compatible 低于 11/edge,则需要 old style embed flash (classid)。如果没有 X-UA-Compatible 或值为 11/edge - 则需要新样式为 html 中的 type="application/x-shockwave-flash"

于 2016-02-16T17:31:15.913 回答