gpt4 book ai didi

javascript - 使用对象标签从 JavaScript 加载 Flash

转载 作者:行者123 更新时间:2023-11-28 19:40:26 24 4
gpt4 key购买 nike

我尝试从外部源或本地源加载 flash(swf 文件),

出于某种原因,我在 html 中使用对象标签来包含 flash,如果我直接在对象标签中加载闪存,它将完美地工作,如下所示:

<object height="100" width="100" data="helloworld.swf" id="flash"></object>

接下来,我需要从 JavaScript 动态加载 Flash,但出现了几个问题:

var flash=document.getElementById("flash");
flash.setAttribute("data","helloworld.swf");

上面的代码在 Chrome 中运行良好,但在 IE 中不起作用(我的 IE 是 Windows 8 上的 IE11)

如果我将对象标签修改为iframe标签,那么它就可以工作,但我需要它是对象标签,

有什么解决方案吗?

最佳答案

您可以通过读取对象来强制刷新:

var flash = document.getElementById("flash");
flash.setAttribute("data","helloworld.swf");

var clone = flash.cloneNode(true);
flash.parentNode.replaceChild(clone, flash);

关于javascript - 使用对象标签从 JavaScript 加载 Flash,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25181523/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com