2014-05-05 71 views
-1

可以自動關閉此窗口Javascript?怎麼樣?非常感謝使用Javascript關閉div

原來是這樣,但現在如下代碼塊:

CSS

#avviso{ 
    width:200px; /* Larghezza del box */ 
    padding:5px; position:fixed; z-index:5000;} 
    .box-avviso{ 
    border:4px double #940F04; /* Colore del bordo */ 
    -webkit-border-radius: 10px; -moz-border-radius: 10px; border-radius: 10px; -webkit-box-shadow: 8px 8px 6px #909090; -moz-box-shadow: 8px 8px 6px #909090; box-shadow: 8px 8px 6px #909090; 
    background-color: #FFEAE9; /* Colore di sfondo */ 
    padding: 8px; font-family: Verdana, Geneva, sans-serif; 
    color: #003366; /* Colore del testo */ 
    } 
    .testo-avviso { /* Stile di AVVISO */ 
    font-size:18pt; 
    font-weight:bold; 
    color:#B4045F; 
    text-shadow: 0px 0px 10px #BA55D3;} 

HTML代碼

<div id="avviso" style="left:20px; top:100px; padding:0;"> 
    <div align="right" style="margin-bottom:-15px;"><b> 
<a href="javascript:closeit()" > 
<font face="Arial" size="1">CHIUDI</font>&nbsp;<img valign="middle" src="https://lh6.googleusercontent.com/-80LmoXXMIi0/TnsyYeeRVnI/AAAAAAAAUgc/RShnbWF2L_c/chiudi.png" style="vertical-align:middle;" border="0"/></a></b></div> 
    <br/> 
    <fieldset class="box-avviso"> 
    <legend class="testo-avviso" align="center"></legend> 
     Nuova Comunicazione<br/> 
    </fieldset> 
    </div> 

的JavaScript

function closeit(){ 
document.getElementById("avviso").style.visibility = "hidden"; 
} 

回答

0

試試這個

<script> 
    function closeit(){ 
    document.getElementById('avviso').setAttribute("style", "display:none"); 
} 
setTimeout("closeit", 3000); 
</script> 
+0

我希望它可以在3秒鐘後自動關閉許多謝謝 – user3604318

+0

Editted回答請嘗試.. – Jameem

+0

**我試過但它不起作用** – user3604318

0
function closeit(){ 
    document.getElementById("avviso").style.display = "none"; 
} 

如果您正在使用jQuery,你也可以通過做這樣的實現,

function closeit() 
{ 
    $('#avviso').hide(); 
}