[转自横渡博客]公告DIV实现

<div id="affiche" ondblclick="closeDiv();" style="BORDER-RIGHT: black 1px outset; BORDER-TOP: black 1px outset; BORDER-LEFT: black 1px outset; WIDTH: 30%; CLIP: rect(auto auto auto auto); BORDER-BOTTOM: black 1px outset; POSITION: absolute; HEIGHT: 30%; BACKGROUND-COLOR: whitesmoke; TEXT-ALIGN: center;"align="center">
            
<table height="100%" width="100%">
                
<tr>
                    
<td vAlign="middle" align="center" height="100%">
                                此处为公告内容
                            
<div id="timeout"></div>
                    
</td>
                
</tr>
            
</table>
        
</div>
            
<script language="javascript">
        
            
var intOut=10;
            TimeDiv();
            
            
function closeDiv()
            {
                document.getElementById(
"affiche").style.display = "none";
            }
            
            
function TimeDiv()
            {
                
--intOut;
                
if ( intOut>1 )
                {
                    window.setTimeout( 
"TimeDiv()",1000 );
                    document.getElementById(
"timeout").innerText=intOut + "秒后/双击窗口自动关闭!";
                }
                
else
                {
                    closeDiv();
                }
            }
            
            
var objDiv = document.getElementById("affiche");
            SetDiv();
            
            
function SetDiv()
            { 
                objDiv.style.top 
= (document.body.offsetHeight - objDiv.offsetHeight)/2 + document.body.scrollTop;
                objDiv.style.left 
= (document.body.offsetWidth - objDiv.offsetWidth)/2
                   if ( intOut>1 )
                {
                    window.setTimeout( 
"SetDiv()",200 );
                }
            }
            
            
</script>
posted @ 2005-04-17 13:35  烈马狂生  阅读(441)  评论(0编辑  收藏  举报