javascript - 隐藏 DIV 在 Opera 中无法正常工作

标签 javascript opera

我的代码在 IE8、Firefox 和 Safari 中运行良好。但它在 Opera 中无法正常工作。 发生的情况是 DIV 被隐藏,但 DIV 占用的空间仍然出现在我的网页中。

<div  style=" z-index:-1;height :380; width:760; position:relative; text-align:center" id="new-add">
    <object id="banner-flash" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" 
    codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" 
        width="769" height="382" top="0"> 
    <param name="movie"  value="exp.swf" /> 
    <param name="quality" value="high" /> 
    <param name="bgcolor" value="#ffffff" /> 
    <param name="wmode" value="transparent" />
    <embed src="exp.swf" wmode="transparent" quality="high" bgcolor="#ffffff" width="780" height="382"
 name="mymoviename" align="" type="application/x-shockwave-flash" 
    pluginspage="http://www.macromedia.com/go/getflashplayer"> 
    </embed> 
    </object> 
</div>

<div  id="fechar-link" style=" font-family: Verdana,Arial,Helvetica,sans-serif; font-style: normal; 
    font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; 
    font-stretch: normal; text-decoration: none; text-align:center" >
    <a href="#" onclick="
        document.getElementById('new-add').style.height =0;
        document.getElementById('banner-flash').style.height =0;
        document.getElementById('fechar-link').style.height  = 0;

        document.getElementById('new-add').style.visibility ='hidden';
        document.getElementById('banner-flash').style.visibility ='hidden';
        document.getElementById('fechar-link').style.visibility ='hidden';  "  >Close</a>
        </div>

我需要做什么,DIV占用的空间才会消失?

谢谢

最佳答案

你可以试试 style.display 属性:

Hide

document.getElementById('YourElem').style.display = 'none';

Show

document.getElementById('YourElem').style.display = '';

编辑:在此答案中将 PorneL 评论纳入帐户

关于javascript - 隐藏 DIV 在 Opera 中无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/264766/

相关文章:

javascript - Opera 中的 document.hasFocus?

javascript - 全日历 : trouble rendering events with ajax when pressing 'prev' or 'next'

javascript - 如何在JS和TS中使用map和filter获取字符串数组?

javascript - 在 Vue.js 的 props 中使用过滤器

javascript - 如果代码被篡改太多,现场的音频播放器会变得脆弱

javascript - 单击浏览器的后退按钮后,Opera 浏览器不会在页面上触发 JS 或服务器端代码 (JSP)

opera - Opera 12.0 中没有 WebGL 实现吗?

javascript - Opera 默认捕获事件吗?正确的行为是什么?

javascript - 如何将 SVG 图像连接到选择菜单?