使用Javascript关闭div

时间:2014-05-05 13:00:15

标签: javascript

有可能自动关闭此窗口Javascript吗?怎么样?非常感谢

这是这样,但现在遵循代码块:

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"; 
} 

2 个答案:

答案 0 :(得分:0)

试试这个

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

答案 1 :(得分:0)

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

如果你正在使用jquery,你也可以这样做,

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