2

我的代码在 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 占用的空间消失?

谢谢

4

2 回答 2

8

您可以尝试 style.display 属性:

隐藏

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

显示

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

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

于 2008-11-05T10:21:46.787 回答
0

我不知道它是否会解决您的问题,但您可以尝试使用:

document.getElementById("xxx").display = "none";

代替

document.getElementById("xxx").style.visibility = "hidden";
于 2008-11-05T10:19:44.480 回答