在右下角彈出窗口,,常用于廣告代碼,,或一些大網(wǎng)站的用戶信息提示,并且會自動隱藏,,可以設(shè)置時間間隔,,彈出窗口的位置和大小,,當然,,窗口內(nèi)容全靠你定了,,將JS保存為JS文件,方便你調(diào)用,。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www./TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www./1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>網(wǎng)頁右下角的信息框</title> </head> <style type="text/css"> #winpop { width:200px; height:0px; position:absolute; right:0; bottom:0; border:1px solid #666; margin:0; padding:1px; overflow:hidden; display:none;} #winpop .title { width:100%; height:22px; line-height:20px; background:#FFCC00; font-weight:bold; text-align:center; font-size:12px;} #winpop .con { width:100%; height:90px; line-height:80px; font-weight:bold; font-size:12px; color:#FF0000; text-decoration:underline; text-align:center} #silu { font-size:12px; color:#666; position:absolute; right:0; text-align:right; text-decoration:underline; line-height:22px;} .close { position:absolute; right:4px; top:-1px; color:#FFF; cursor:pointer} </style> <script type="text/javascript"> function tips_pop(){ var MsgPop=document.getElementById("winpop"); var popH=parseInt(MsgPop.style.height);//將對象的高度轉(zhuǎn)化為數(shù)字 if (popH==0){ MsgPop.style.display="block";//顯示隱藏的窗口 show=setInterval("changeH('up')",2); } else { hide=setInterval("changeH('down')",2); } } function changeH(str) { var MsgPop=document.getElementById("winpop"); var popH=parseInt(MsgPop.style.height); if(str=="up"){ if (popH<=100){ MsgPop.style.height=(popH+4).toString()+"px"; } else{ clearInterval(show); } } if(str=="down"){ if (popH>=4){ MsgPop.style.height=(popH-4).toString()+"px"; } else{ clearInterval(hide); MsgPop.style.display="none"; //隱藏DIV } } } window.onload=function(){ //加載 document.getElementById('winpop').style.height='0px'; setTimeout("tips_pop()",800); //3秒后調(diào)用tips_pop()這個函數(shù) } </script> <body> <div id="silu"> <button onclick="tips_pop()">3秒后會在右下角自動彈出窗口,,如果沒有彈出請點擊這個按鈕</button> </div> <div id="winpop"> <div class="title">您有新的短消息!<span class="close" onclick="tips_pop()">X</span></div> <div class="con">1條未讀信息(</div> </div> </body> </html>
|