您的位置:首页 > 其它

右下角动态弹出框,不随滚动条滚动

2015-07-20 10:45 190 查看
//CSS<style type="text/css"> body { background:#333333;} #winpop { width:200px; height:0px; position:fixed; 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>
//JS<script type="text/javascript"> function show_pop(){//显示窗口     document.getElementById("winpop").style.display="block";     timer=setInterval("changeH(4)",2);//调用changeH(4),每0.002秒向上移动一次 } function hid_pop(){//隐藏窗口     timer=setInterval("changeH(-4)",2);//调用changeH(-4),每0.002秒向下移动一次 } //www.jb51.net 脚本之家测试通过 function changeH(addH) {     var MsgPop=document.getElementById("winpop");     var popH=MsgPop.offsetHeight;  //对象高度    if (popH<=100&&addH>0||popH>=4&&addH<0){//如果高度小于等于100(str>0)或高度大于等于4(str<0)         MsgPop.style.height=(popH+addH).toString()+"px";//高度增加或减少4个象素     }     else{//否则         clearInterval(timer);//取消调用,意思就是如果高度超过100象素了,就不再增长了,或高度等于0象素了,就不再减少了         MsgPop.style.display=addH>0?"block":"none"//向上移动时窗口显示,向下移动时窗口隐藏(因为窗口有边框,所以还是可以看见1~2象素没缩进去,这时候就把DIV隐藏掉)     } } window.onload=function(){//加载 setTimeout("show_pop()",800);//0.8秒后调用show_pop() } </script> 
//页面<body> <div id="winpop">     <div class="title">您有新的消息<span class="close" onclick="hid_pop()">X</span></div> <div class="con"><a href='http://www.jb51.net'>脚本之家</a></div> </div> </body>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: