簡體   English   中英

Internet Explorer javascript style.height無法正常工作

[英]internet explorer javascript style.height not working

我正在嘗試為網站創建Cookie策略警報,就像在屏幕頂部的欄一樣簡單。 這個想法是用戶必須在欄消失之前單擊關閉。 該概念在谷歌瀏覽器中可以正常工作,但是在Internet Explorer 9中,單擊時不會改變其高度。

這是我的代碼(我知道這是基本代碼,但不幸的是,這必須歸功於企業使用的平台-

<script language=javascript type='text/javascript'> 
function hideDiv() { 
if (document.getElementById) { // DOM3 = IE5, NS6 
document.getElementById('hideShow').style.height= '0px'; 
} 
else { 
if (document.layers) { // Netscape 4 
document.hideShow.height= '0px'; 
} 
else { // IE 4 
document.all.hideShow.style.height= '0px'; 
} 
} 
} 

function showDiv() { 
if (document.getElementById) { // DOM3 = IE5, NS6 
document.getElementById('hideShow').style.visibility = 'visible'; 
} 
else { 
if (document.layers) { // Netscape 4 
document.hideShow.visibility = 'visible'; 
} 
else { // IE 4 
document.all.hideShow.style.visibility = 'visible'; 
} 
} 
} 
</script> 

<style>
#hideShow{
color:white;
font-family:Gill Sans MT;
text-align:center;
font-height:20px;
</style>

<div id="hideShow" ..etc> 
My content 
<a href="javascript:hideDiv()">Close</a> 
</div> 

另外,如果有人那么善良,請您解釋一下我如何進行設置,以便div'hideShow'一直顯示到被單擊為止,然后再也不會在該計算機上顯示?

如果您需要更多詳細信息,請告訴我。 在此先感謝Rob

問題是必須在hideShow CSS中定義高度。 以及字體大小。 然后,JavaScript必須將height和fontSize設置為0px。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM