質問
IE8、Firefox、およびSafariで私のコードはうまく機能します。ただし、Operaでは正常に動作しません。 何が起こるかというと、DIVは非表示になっていますが、DIVが占めるスペースは私のWebページに表示されたままです。
<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プロパティを試すことができます:
非表示
document.getElementById( 'YourElem')。style.display = 'none';
表示
document.getElementById( 'YourElem')。style.display = '';
編集:この回答でPorneLのコメントをacocuntに追加しました
他のヒント
それが問題を解決するかどうかはわかりませんが、使用してみてください:
document.getElementById("xxx").display = "none";
の代わりに
document.getElementById("xxx").style.visibility = "hidden";
所属していません StackOverflow