2个回答
展开全部
---下面代码是点击登录弹出遮罩,是你要的效果,内容随意改动
//这里主要有两个层 登录层:divLogin 遮罩层:doing
//javascript控制两层显示与否
<script type="text/javascript" language="javascript">
function ShowNo()
{
document.getElementById("doing").style.display="none";
document.getElementById("divLogin").style.display="none";
}
function $(id)
{
return (document.getElementById) ? document.getElementById(id) : document.all[id] ;
}
function showFloat()
{
var range = getRange();
$('doing').style.width = range.width + "px";
$('doing').style.height = range.height + "px";
$('doing').style.display = "block";
document.getElementById("divLogin").style.display="";
}
function getRange()
{
var top = document.body.scrollTop;
var left = document.body.scrollLeft;
var height = document.body.clientHeight;
var width = document.body.clientWidth;
if (top==0 && left==0 && height==0 && width==0)
{
top = document.documentElement.scrollTop;
left = document.documentElement.scrollLeft;
height = document.documentElement.clientHeight;
width = document.documentElement.clientWidth;
}
return {top:top ,left:left ,height:height ,width:width } ;
}
</script>
//这个css样式也要加上
<style type="text/css">
body{margin:0px;}
</style>
//主要代码部分
<body>
<form id="form1" runat="server">
<a href="javascript:void(0)" onclick="showFloat()">登陆</a>
<!--加一个半透明层-->
<div id="doing" style="filter:alpha(opacity=30);-moz-opacity:0.3;opacity:0.3;background-color:#000;width:100%;height:100%;z-index:1000;position: absolute;left:0;top:0;display:none;overflow: hidden;">
</div>
<!--加一个登录层-->
<div id="divLogin" style="border:solid 10px #898989;background:#fff;padding:10px;width:780px;z-index:1001; position: absolute; display:none;top:50%; left:50%;margin:-200px 0 0 -400px;">
<div style="padding:3px 15px 3px 15px;text-align:left;vertical-align:middle;" >
<div>
用户:
<asp:TextBox ID="TxtUserName" runat="server" > </asp:TextBox>
</div>
<div>
密码:
<asp:TextBox ID="TxtUserPwd" runat="server" TextMode="Password" > </asp:TextBox>
</div>
<br/>
<div>
<asp:Button ID="BttLogin" runat="server" Text=" 登 陆 "/>
<input id="BttCancel" type="button" value=" 取 消 " onclick="ShowNo()" />
</div>
</div>
</div>
</form>
//br是用来撑打页面的
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
</body>
//这里主要有两个层 登录层:divLogin 遮罩层:doing
//javascript控制两层显示与否
<script type="text/javascript" language="javascript">
function ShowNo()
{
document.getElementById("doing").style.display="none";
document.getElementById("divLogin").style.display="none";
}
function $(id)
{
return (document.getElementById) ? document.getElementById(id) : document.all[id] ;
}
function showFloat()
{
var range = getRange();
$('doing').style.width = range.width + "px";
$('doing').style.height = range.height + "px";
$('doing').style.display = "block";
document.getElementById("divLogin").style.display="";
}
function getRange()
{
var top = document.body.scrollTop;
var left = document.body.scrollLeft;
var height = document.body.clientHeight;
var width = document.body.clientWidth;
if (top==0 && left==0 && height==0 && width==0)
{
top = document.documentElement.scrollTop;
left = document.documentElement.scrollLeft;
height = document.documentElement.clientHeight;
width = document.documentElement.clientWidth;
}
return {top:top ,left:left ,height:height ,width:width } ;
}
</script>
//这个css样式也要加上
<style type="text/css">
body{margin:0px;}
</style>
//主要代码部分
<body>
<form id="form1" runat="server">
<a href="javascript:void(0)" onclick="showFloat()">登陆</a>
<!--加一个半透明层-->
<div id="doing" style="filter:alpha(opacity=30);-moz-opacity:0.3;opacity:0.3;background-color:#000;width:100%;height:100%;z-index:1000;position: absolute;left:0;top:0;display:none;overflow: hidden;">
</div>
<!--加一个登录层-->
<div id="divLogin" style="border:solid 10px #898989;background:#fff;padding:10px;width:780px;z-index:1001; position: absolute; display:none;top:50%; left:50%;margin:-200px 0 0 -400px;">
<div style="padding:3px 15px 3px 15px;text-align:left;vertical-align:middle;" >
<div>
用户:
<asp:TextBox ID="TxtUserName" runat="server" > </asp:TextBox>
</div>
<div>
密码:
<asp:TextBox ID="TxtUserPwd" runat="server" TextMode="Password" > </asp:TextBox>
</div>
<br/>
<div>
<asp:Button ID="BttLogin" runat="server" Text=" 登 陆 "/>
<input id="BttCancel" type="button" value=" 取 消 " onclick="ShowNo()" />
</div>
</div>
</div>
</form>
//br是用来撑打页面的
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
</body>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询