62,041
社区成员
发帖
与我相关
我的任务
分享
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>点击弹出对话框且背景变暗的效果</title>
<meta http-equiv="content-type" content="text/html;charset=gb2312">
<link href="StyleSheet.css" rel="stylesheet" type="text/css" />
<script language="javascript">
function locking()
{
document.all.ly.style.display="block";
document.all.ly.style.width=document.body.clientWidth; //设置层1宽度等于body宽度,width=100%也可以,不过有一些误差,所以最好用这个
document.all.ly.style.height=document.body.clientHeight; //设置层1高度满屏
document.all.Layer2.style.display='block';
document.all.Layer2.style.top = document.body.clientHeight/2-document .getElementById ("Layer2").clientHeight/2//设置层2的距顶位置居中算法
document.all.Layer2.style.left = document.body.clientWidth/2-document .getElementById ("Layer2").clientWidth/2;//设置层2的距左位置居中算法
}
function Lock_CheckForm(theForm)
{
document.all.ly.style.display='none';
document.all.Layer2.style.display='none';
}
</script>
</head>
<body>
<p>
<input type="button" value="弹出窗口" onclick="locking();"></p>
<!--这是要覆盖网页的层1,不必写任何东西-->
<div id="ly">
</div>
<!--浮层2框架开始-->
<div id="Layer2">
<div class="msg_title">
<a href="#" class="myfont" onclick="Lock_CheckForm(this);">[关闭]</a></div>
<div class="msg_content">
<p>
确定退出?</p>
<p>
<input type="button" value="确定" />
<input type="button" onclick="showclose();" value="取消" /></p>
</div>
</div>
<!--浮层2框架结束-->
</body>
</html>
a:link
{
color: #FFFFFF;
text-decoration: none;
}
a:visited, a:hover, a:active
{
text-decoration: none;
}
.myfont
{
font-size: 12px;
}
#ly
{
position: absolute;
top: 0px;
filter: alpha(opacity=60);
background-color: #777;
z-index: 2;
left: 0px;
display: none;
}
#Layer2
{
position: absolute;
z-index: 3;
background-color: #fff;
display: none;
width: 540px;
height: 300px;
}
.msg_title
{
border: 1px solid #2982BA;
background-color: #ADDAFB;
border-bottom: 0;
text-align: right;
vertical-align: bottom;
cursor :move; /*设置指针的移动图标,若不想移动,可以去掉此行*/
/*与height大小一样可以垂直居中,适用于单行情况*/
height: 25px;
line-height: 25px;
overflow: hidden;
/*与height大小一样可以垂直居中,适用于单行情况*/
}
.msg_content
{
border: 1px solid #2982BA;
background-color: #E6F7FF;
text-align: center;
height: 275px;
padding-top: 50px;
}
/// <summary>
/// 打开指定大小位置的模式对话框
/// </summary>
/// <param name="url"></param>
/// <param name="width"></param>
/// <param name="height"></param>
/// <param name="top"></param>
/// <param name="left"></param>
public static void ShowModalDialog(string url, int width, int height, int top, int left)
{
string features = "dialogWidth:" + width.ToString() + "px"
+ ";dialogHeight:" + height.ToString() + "px"
+ ";dialogLeft:" + left.ToString() + "px"
+ ";dialogTop:" + top.ToString() + "px"
+ ";center:yes;help=no;resizable:no;status:no;scroll=yes";
string js = @"<script language=javascript>
showModalDialog('" + url + "','','" + features + "');</script>";
HttpContext.Current.Response.Write(js);
}
<script language="javascript">
function popupkind(xdm)
{
url="ThisTerm2Add.aspx?xdm="+xdm
hr=window.showModalDialog(url,'',"dialogHeight:300px;dialogWidth:300px;dialogLeft:60px;dialogTop:30px;center:1;status:1;title:0;")
}
</script>