怎样用jquery弹出一个层后,页面变灰不能操作
展开全部
//获得坐标
function getPosition() {
var top = document.documentElement.scrollTop;
var left = document.documentElement.scrollLeft;
var height = document.documentElement.clientHeight;
var width = document.documentElement.clientWidth;
//top=500;
left = 200;
//height=0;
width = 500;
return { top: top, left: left, height: height, width: width };
}
//屏蔽输入,显示蒙板
function showMask(id) {
var obj = document.getElementById(id);
obj.style.width = document.body.clientWidth;
obj.style.height = document.body.clientHeight;
obj.style.display = "block";
}
//隐藏蒙板
function hideMask(id) {
document.getElementById(id).style.display = "none";
}
//显示登录
function showPop(id) {
var width = 300; //弹出框的宽度
var height = 170; //弹出框的高度
var obj = document.getElementById(id);
obj.style.display = "block";
obj.style.position = "absolute";
obj.style.zindex = "10";
obj.style.overflow = "hidden";
obj.style.width = width + "px";
obj.style.height = height + "px";
var Position = getPosition();
leftadd = (Position.width - width) / 2;
topadd = (Position.height - height) / 2;
obj.style.top = (Position.top + topadd) + "px";
obj.style.left = (Position.left + leftadd) + "px";
window.onscroll = function() {
var Position = getPosition();
obj.style.top = (Position.top + topadd) + "px";
obj.style.left = (Position.left + leftadd) + "px";
};
}
//隐含
function hidePop(id) {
document.getElementById(id).style.display = "none";
}
<!--蒙板-->
<div id="mask" style="filter: Alpha(opacity=30); -moz-opacity: 0.3; -khtml-opacity: 0.3;
opacity: 0.3; background-color: #000; width: 100%; height: 100%; z-index: 5px;
position: absolute; left: 0; top: 0; display: none; overflow: hidden;">
</div>
<!--蒙板结束-->
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询