作者:八卦男1002_426 | 来源:互联网 | 2023-09-25 16:34
网站div浮动层同时网站背景变灰代码兼容firefox,谷歌浏览器(Chrome)效果图:
![div浮动层](https://img.php1.cn/3cd4a/1eebe/cd5/fb32005f2115b419.webp)
Sign in处代码:Sign in
function ShowLoginWindow()
{
if(document.getElementById("fullbg"))
{
document.body.removeChild(document.getElementById("fullbg"));
}
if(document.getElementById("deliverywin"))
{
document.body.removeChild(document.getElementById("deliverywin"));
}
deliverywinopen();
}
function deliverywinopen()
{
var bgDiv=document.createElement("div");
bgDiv.id="fullbg";
bgDiv.className="fullwinbg";
bgDiv.style.px";
var scrollHeight=document.body.scrollHeight+20;
bgDiv.style.px";
bgDiv.innerHTML="";
document.body.appendChild(bgDiv);
var deliverywin=document.createElement("div");
deliverywin.id="deliverywin";
deliverywin.className="deliverywindow";
deliverywin.innerHTML="";
/* var mouse=mouseCoords(document.getElementById("Table13"));
var x=mouse.x+217;
var y=mouse.y+130;
deliverywin.style.left=x+"px";
deliverywin.style.top=y+"px";*/
document.body.appendChild(deliverywin);
centerwh(deliverywin);
}
function centerwh(obj)
{
var h1 = document.body.clientHeight;
var h2 = document.documentElement.clientHeight;
var isXhtml = (h2<=h1&&h2!=0)?true:false;
var body = isXhtml?document.documentElement:document.body;
var wh={left:0,top:0};
var vwh={w:0,h:0};
vwh.w=navigator.userAgent.indexOf('MSIE') >= 0?parseInt(body.clientWidth):parseInt(window.innerWidth);
vwh.h=navigator.userAgent.indexOf('MSIE') >= 0?parseInt(body.clientHeight):parseInt(window.innerHeight);
wh.left=(vwh.w/2)-108;
wh.top=document.documentElement.scrollTop+document.body.scrollTop+(vwh.h/2)-150;这个地方要注意:即获取高度时使用document.documentElement.scrollTop+document.body.scrollTop,经测试,代码在IE、Firefox、Chrome下都能显示正常了。
document.getElementById("deliverywin").style.top = wh.top + "px";
document.getElementById("deliverywin").style.left = wh.left + "px";
}
function windowclose()
{
if(document.getElementById("fullbg"))
{
document.body.removeChild(document.getElementById("fullbg"));
}
if(document.getElementById("deliverywin"))
{
document.body.removeChild(document.getElementById("deliverywin"));
}
}
在loginifram.aspx页面处的关闭代码:close