2008-11-05 43 views
2

我的代碼在IE8,Firefox和Safari中效果很好。但它在Opera中無法正常工作。 會發生什麼,DIV是隱藏的,但DIV佔用的空間仍然出現在我的網頁中。隱藏DIV在Opera中無法正常工作

<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佔用的空間消失了?

感謝

回答

8

你可以嘗試的風格。展示物業:

隱藏

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

顯示

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

編輯:接過PorneL評論到acocunt在這個答案

+0

用的style.display的問題是,撤消它,你必須知道是否顯示元素作爲塊或內聯。 – bart 2008-11-05 11:34:37

0

我不知道這是否會解決你的問題,但你可以嘗試使用:

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

,而不是

document.getElementById("xxx").style.visibility = "hidden"; 
相關問題