微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

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

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

更新02/08/2013
我在Safari(5.1.7)中发现了同样的问题

解决方法:

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

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

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

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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐