<html>
<head>
<title>
jquery弹出模式窗口的例子_www.jb200.com</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<style type="text/css">
.black_overlay{
display: none;
position: absolute;
top: 0%;
left: 0%;
width: 100%;
height: 100%;
background-color: black;
z-index:1001;
-moz-opacity: 0.8;
opacity:.80;
filter: alpha(opacity=80);
}
.white_content {
display: none;
position: absolute;
top: 25%;
left: 25%;
width: 50%;
height: 50%;
padding: 16px;
border: 2px solid orange;
background-color: white;
z-index:1002;
overflow: auto;
}
</style>
<script language="
javascript">
function openWindow(){
document.getElementById('light').style.display='block';
document.getElementById('fade').style.display='block';
}
function closeWindow(){
document.getElementById('light').style.display='none';
document.getElementById('fade').style.display='none';
}
</script>
</head>
<body>
<p>可以根据自己要求修改
css样式
<input type="button" value="点击这里打开窗口" onclick="openWindow()"/></p>
</body>
<div id="light" class="white_content">
This is the lightbox content.
<a href="#" onClick="closeWindow()"> Close</a></div>
<div id="fade" class="black_overlay"></div>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jquery弹出层_www.jb200.com</title>
<script type="text/javascript" src="jquery-1.4.2.min.js" ></script>
<script type="text/javascript">
$(function()
{
$("#btnShow").click(function()
{
var str="
弹出对话框示例";
$(".form").html(str);
$("#BgDiv").css({ display:"block",height:$(document).height()});
var yscroll=document.documentElement.scrollTop;
$("#DialogDiv").css("top","100px");
$("#DialogDiv").css("display","block");
document.documentElement.scrollTop=0;
});
$("#btnClose").click(function()
{
$("#BgDiv").css("display","none");
$("#DialogDiv").css("display","none");
});
});
</script>
<script type="text/javascript" language="javascript">
var _move=false;//移动标记
var _x,_y;//鼠标离控件左上角的相对位置
$(document).ready(function(){
$("#DialogDiv").click(function(){
}).mou
sedown(function(e){
_move=true;
_x=e.pageX-parseInt($("#DialogDiv").css("left"));
_y=e.pageY-parseInt($("#DialogDiv").css("top"));
$("#div2").fadeTo(20, 0.25);//点击后开始拖动并透明显示
});
$(document).mousemove(function(e){
if(_move){
var x=e.pageX-_x;//移动时根据鼠标位置计算控件左上角的绝对位置
var y=e.pageY-_y;
$("#DialogDiv").css({top:y,left:x});//控件新位置
}
}).mouseup(function(){
_move=false;
$("#DialogDiv").fadeTo("fast", 1);//松开鼠标后停止移动并恢复成不透明
});
});
</script>
<style type="text/css">
body,h2{margin:0 ; padding:0;}
#BgDiv{background-color:#e3e3e3; position:absolute; z-index:99; left:0; top:0; display:none; width:100%; height:1000px;opacity:0.5;filter: alpha(opacity=50);-moz-opacity: 0.5;}
#DialogDiv{position:absolute;width:400px; left:50%; top:50%; margin-left:-200px; height:auto; z-index:100;background-color:#fff; border:1px #8FA4F5 solid; padding:1px;}
#DialogDiv h2{ height:25px; font-size:14px; background-color:#8FA4F5; position:relative; padding-left:10px;
line-height:25px;}
#DialogDiv h2 a{position:absolute; right:5px; font-size:12px; color:#000000}
#DialogDiv .form{padding:10px;}
</style>
</head>
<body >
<div id="BgDiv"></div>
<div id="DialogDiv" style="display:none">
<h2 style="cursor:move;">弹出层标题<a href="#" id="btnClose">关闭</a></h2>
<div class="form">
</div>
</div>
<p> </p>
<p align="center">
<input value="弹出" type="button" id="btnShow" />
</p>
</body>
</html>