<style type="text/css">
body { background:#333333;}
#winpop { width:200px; height:0px; position:absolute; right:0; bottom:0; border:1px solid #999999; margin:0; padding:1px; overflow:hidden;display:none; background:#FFFFFF}
#winpop .title { width:100%; height:20px; line-height:20px; background:#FFCC00; font-weight:bold; text-align:center; font-size:12px;}
#winpop .con { width:100%; height:80px; line-height:80px; font-weight:bold; font-size:12px; color:#FF0000; text-decoration:underline; text-align:center}
#silu { font-size:13px; color:#999999; position:absolute; right:0;bottom:0px; text-align:right; text-decoration:underline; line-height:22px;}
.close { position:absolute; right:4px; top:-1px; color:#FFFFFF; cursor:pointer}
</style>
<script type="text/javascript">
function show_pop(){//顯示窗口
document.getElementById("winpop").style.display="block";
timer=setInterval("changeH(4)",2);//調(diào)用changeH(4),每0.002秒向上移動(dòng)一次
}
function hid_pop(){//隱藏窗口
timer=setInterval("changeH(-4)",2);//調(diào)用changeH(-4),每0.002秒向下移動(dòng)一次
}
//www.jb51.net 腳本之家測(cè)試通過
function changeH(addH) {
var MsgPop=document.getElementById("winpop");
var popH=parseInt(MsgPop.style.height||MsgPop.currentStyle.height);//用parseInt將對(duì)象的高度轉(zhuǎn)化為數(shù)字,以方便下面比較(JS讀<style>中的height要用"currentStyle.height")
if (popH<=100&&addH>0||popH>=4&&addH<0){//如果高度小于等于100(str>0)或高度大于等于4(str<0)
MsgPop.style.height=(popH+addH).toString()+"px";//高度增加或減少4個(gè)象素
}
else{//否則
clearInterval(timer);//取消調(diào)用,意思就是如果高度超過100象素了,就不再增長了,或高度等于0象素了,就不再減少了
MsgPop.style.display=addH>0?"block":"none"http://向上移動(dòng)時(shí)窗口顯示,向下移動(dòng)時(shí)窗口隱藏(因?yàn)榇翱谟羞吙?所以還是可以看見1~2象素沒縮進(jìn)去,這時(shí)候就把DIV隱藏掉)
}
}
window.onload=function(){//加載
setTimeout("show_pop()",800);//0.8秒后調(diào)用show_pop()
}
</script>
<body>
<div id="silu">
<button onclick="show_pop()">測(cè)試按鈕</button>
</div>
<div id="winpop">
<div class="title">您有新的消息<span class="close" onclick="hid_pop()">X</span></div>
<div class="con"><a >腳本之家</a></div>
</div>
</body>
聯(lián)系客服