网站div浮动层同时网站背景变灰代码兼容firefox,谷歌浏览器(Chrome)

网站div浮动层同时网站背景变灰代码兼容firefox,谷歌浏览器(Chrome)效果图:
div浮动层

Sign in处代码:<a class="signinlink" οnclick="javascript:ShowLoginWindow()">Sign in</a>

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.width=document.body.scrollWidth+"px";
var scrollHeight=document.body.scrollHeight+20;
bgDiv.style.height=scrollHeight+"px";
bgDiv.innerHTML="<iframe frameborder=\"0\" scrolling=\"no\" src=\"about:blank\" style=\"background-color:#FFFFFF;width:"+document.body.scrollWidth+"px;height:"+scrollHeight+"px;\"></iframe>";
document.body.appendChild(bgDiv);
var deliverywin=document.createElement("div");
deliverywin.id="deliverywin";
deliverywin.className="deliverywindow";
deliverywin.innerHTML="<iframe id=\"deliveryiframe\" frameborder=\"0\" allowtransparency=\"true\" scrolling=\"no\" src=\"loginifram.aspx\" style=\" width:220px; height:310px;\"></iframe>";
/* 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页面处的关闭代码:<a href="#" class="two" onClick="parent.windowclose();">close</a>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值