DIV 弹出层

来源:互联网 发布:设置软件管理员权限 编辑:程序博客网 时间:2024/05/02 00:10

//弹出缓慢居中的层
//divid 层的ID  timeNum  设置每次执行的时间
//页面调用   

   function showDiv() {           
 showSlowCenter("messsagessss", "10");        
showCenter("messsagessss");   }

function showSlowCenter(divid,timeNum) {    var div = document.getElementById(divid);    div.style.display = "block";    var posX, posY;    var top = (window.screen.height - 420) / 2;    var left = (window.screen.width - 400) / 2;    if (window.innerHeight) {        posX = window.pageXOffset;        posY = window.pageYOffset;    }    else if (document.documentElement && document.documentElement.scrollTop) {        posX = document.documentElement.scrollLeft;        posY = document.documentElement.scrollTop;    }    else if (document.body) {        posX = document.body.scrollLeft;        posY = document.body.scrollTop;    }    div.style.left = (left) + "px";    var toppx = -100;    var hight = (posY + top) - 30;    if (toppx < hight) setTimeout(function() { showBox(toppx, divid, hight, timeNum) }, timeNum);}//弹出居中的层function showCenter(divid) {    var div = document.getElementById(divid);    div.style.display = "block";    var posX, posY;    var top = (window.screen.height - 420) / 2;    var left = (window.screen.width - 400) / 2;    if (window.innerHeight) {        posX = window.pageXOffset;        posY = window.pageYOffset;    }    else if (document.documentElement && document.documentElement.scrollTop) {        posX = document.documentElement.scrollLeft;        posY = document.documentElement.scrollTop;    }    else if (document.body) {        posX = document.body.scrollLeft;        posY = document.body.scrollTop;    }    div.style.top = (posY + top) + "px";    div.style.left = (left) + "px";}function showBox(toppx, obj, tops, timeNum) {    document.getElementById(obj).style.top = toppx + "px";    var toppx = toppx + 6;    if (toppx < tops) setTimeout(function() { showBox(toppx, obj, tops, timeNum) }, timeNum);}function showBox2(o) {    if (o == undefined) o = document.getElementById("Div1");    o.style.height = o.clientHeight + 6 + "px";    if (o.clientHeight < 240) setTimeout(function() { showBox2(o) }, 5);}function closebox(o) {    if (o == undefined) o = document.getElementById("Div1");    o.style.height = o.clientHeight - 6 + "px";    if (o.clientHeight > 0) setTimeout(function() { closebox(o) }, 5);}


 


 

原创粉丝点击