在 IE 的 html 页面中重新加载嵌入的 swf

reload embedded swf in html page in IE

我在 html 页面中嵌入了一个 swf 文件。我想在不刷新页面的情况下重新加载 swf 文件。

这里问了同样的问题:reload/ reset embedded swf on click

我尝试了接受的答案,它在 chrome:

中有效
var obj = $("object#flash_99674493");
obj.html(obj.html());

但是在IE中好像不行。如何让它在 IE 中工作?

如果您的 .swf 嵌入了 <object>,请使用 data 属性:

document.getElementById('flash_99674493').data += '';

对于嵌入 <embed> 的,使用 src:

document.getElementById('flash_99674493').src += '';

将空字符串添加到 datasrc 会导致它们重新加载。

在 IE 中,我们必须用相同的对象替换对象:

var o = document.getElementById('flash_99674493');
var n = o.cloneNode(!0);
o.parentNode.insertBefore(n, o);
o.parentNode.removeChild(o);

您是否尝试过使用包装器使用常规 JavaScript?我在旧浏览器(如 IE 9)上对此进行了测试。

<!-- wrapper around your flash object -->
<div id="flash-content">
        <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="200" height="200" id="SoundSpectrum2" align="middle">
            <param name="movie" value="SoundSpectrum2.swf" />
            <param name="quality" value="high" />
            ...

然后 JavaScript:

function reloadFlash() {
   var content = document.getElementById('flash-content');
   var currentArray = [];

   while (content.firstChild) {
      currentArray.push(content.firstChild.cloneNode(true));
      content.removeChild(content.firstChild);
   }

   currentArray.forEach(function(item) {
      content.appendChild(item)
   });
}