IE10/Safari无法隐藏iFrame中的对象/ Flash

Jai*_*der 4 javascript css flash iframe internet-explorer-10

我在iFrame中有一个Flash动画.当我试图隐藏它时,IE10会保持显示并重叠其他内容. 这是一个例子.

<body style="background-color: #EEE">
    Testing IE10
    <div id="swfDiv">
        <iframe src="swf.html" width="500" height="50"></iframe>
        <br />
        <button onclick="document.getElementById('swfDiv').style.display='none'">Hide</button>
    </div>
    <div style="background-color: #DDD">
        This try to hide the animation, but it is not working on IE10.  <br/> It works fine in others browsers and earlier versions of IE.
    </div>
</body>
Run Code Online (Sandbox Code Playgroud)

IE10

更新02/08/2013 我在Safari(5.1.7)中发现了同样的问题 在此输入图像描述

Jai*_*der 5

显然,最好的解决方案是将其移出屏幕:

.xhide
{
    display: block;
    position: absolute;
    left:-9999px;
}
Run Code Online (Sandbox Code Playgroud)

我们可以在点击时添加这个类来隐藏它,例如:

document.getElementById('swfDiv').className = "xhide";
Run Code Online (Sandbox Code Playgroud)