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

标签 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>

IE10

2013 年 2 月 8 日更新 我在 Safari (5.1.7) 中发现了同样的问题 enter image description here

最佳答案

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

.xhide
{
    display: block;
    position: absolute;
    left:-9999px;
}

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

document.getElementById('swfDiv').className = "xhide";

关于javascript - IE10/Safari 无法隐藏 iFrame 中的对象/Flash,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14609136/

相关文章:

javascript - javascript中可以赋给变量的值有哪些?

css - 单击可折叠标题的背景可折叠内容但主图标未更改

jquery - 使用 ReactJS 和 React Router 更改每个路由的页面背景颜色?

flash - 如何绕过 "Adobe Flash Player has stopped a potentially unsafe operation."?

javascript - 使用 JavaScript 读取远处的图像并获取其元数据

javascript - 使用 google/token 添加更多时间,能够在一天中的任何时间获取 cal 事件?

PHP 与 JavaScript 或 Flash

iphone - 如何触发“相机”应用之类的明亮闪光?

Javascript keyup shiftKey 不是预期的行为

html - Css 过渡不起作用