jQuery弹出窗口完整代码
来源:互联网 发布:mac 文稿 照片图库 编辑:程序博客网 时间:2024/06/03 21:28
原文链接
http://www.cnblogs.com/jihua/archive/2012/10/08/2715175.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弹出窗口 - 计划-博客园</title>
<meta name="keywords" content="www.cnblogs.com/jihua"/>
<style type="text/css">
.window{
width:250px;
background-color:#d0def0;
position:absolute;
padding:2px;
margin:5px;
display:none;
}
.content{
height:150px;
background-color:#FFF;
font-size:14px;
overflow:auto;
}
.title{
padding:2px;
color:#0CF;
font-size:14px;
}
.title img{
float:right;
}
</style>
<script type="text/javascript" src="http://down.hovertree.com/jquery/jquery-1.7.2.min.js"></script>
<script type="text/javascript" language="javascript">
$(document).ready(function () {
$("#btn_center").click(function () {
popCenterWindow();
});
$("#btn_right").click(function () {
popRightWindow();
});
$("#btn_left").click(function () {
popLeftWindow();
});
});
</script>
</head>
<body>
<div style="width:600px;margin-left:auto;margin-right:auto;margin-top:160px;">
<input type="button" value="居中窗口" id="btn_center" />
<input type="button" value="居左下角" id="btn_left" />
<input type="button" value="居右下角" id="btn_right" />
</div>
<div class="window" id="center">
<div id="title" class="title"><img src="http://pic002.cnblogs.com/images/2012/451207/2012100814082487.jpg" alt="关闭" />计划 博客园-居中窗口</div>
<div class="content">jihua.cnblogs.com</div>
</div>
<div class="window" id="left">
<div id="title2" class="title"><img src="http://pic002.cnblogs.com/images/2012/451207/2012100814082487.jpg" alt="关闭" />计划 博客园-居左窗口</div>
<div class="content">jihua.cnblogs.com</div>
</div>
<div class="window" id="right">
<div id="title3" class="title"><img src="http://pic002.cnblogs.com/images/2012/451207/2012100814082487.jpg" alt="关闭" />计划 博客园-居右窗口</div>
<div class="content">jihua.cnblogs.com</div>
</div>
<script type="text/javascript">
//获取窗口的高度
var windowHeight;
//获取窗口的宽度
var windowWidth;
//获取弹窗的宽度
var popWidth;
//获取弹窗高度
var popHeight;
function init(){
windowHeight=$(window).height();
windowWidth=$(window).width();
popHeight=$(".window").height();
popWidth=$(".window").width();
}
//关闭窗口的方法
function closeWindow(){
$(".title img").click(function(){
$(this).parent().parent().hide("slow");
});
}
//定义弹出居中窗口的方法
function popCenterWindow(){
init();
//计算弹出窗口的左上角Y的偏移量
var popY=(windowHeight-popHeight)/2;
var popX=(windowWidth-popWidth)/2;
//alert('jihua.cnblogs.com');
//设定窗口的位置
$("#center").css("top",popY).css("left",popX).slideToggle("slow");
closeWindow();
}
function popLeftWindow(){
init();
//计算弹出窗口的左上角Y的偏移量
var popY=windowHeight-popHeight;
//var popX=-(windowWidth-popWidth);
//alert(popY);
//设定窗口的位置
$("#left").css("top",popY-50).css("left",50).slideToggle("slow");
closeWindow();
}
function popRightWindow(){
init();
//计算弹出窗口的左上角Y的偏移量
var popY=windowHeight-popHeight;
var popX=windowWidth-popWidth;
//alert(www.cnblogs.com/jihua);
//设定窗口的位置
$("#right").css("top",popY-50).css("left",popX-50).slideToggle("slow");
closeWindow();
} </script>
</body>
</html>
0 0
- jQuery弹出窗口完整代码
- jQuery弹出窗口完整代码
- jquery 弹出一个淡出窗口示例代码
- Jquery教程:JS弹出窗口DIV层效果代码
- jquery实现弹出窗口效果的实例代码
- jquery实现弹出窗口
- jquery:弹出输入窗口
- Jquery 弹出多级窗口
- JQuery 弹出窗口效果
- 一些Jquery弹出窗口
- jquery win7弹出窗口
- jquery 弹出窗口
- 封装jquery弹出窗口
- jquery 弹出窗口
- jquery 弹出窗口
- 弹出窗口--Jquery
- Jquery自定义弹出窗口
- JQuery 模拟弹出窗口
- Activiti学习——环境搭建
- 剑指offer(51)-字符流中第一个不重复的字符
- 人脸识别助力网络支付实名制落地推进
- Serializable和Parcelable的解析与使用
- android sdk 目录结构
- jQuery弹出窗口完整代码
- cocoapods在OS X EI Capitan系统安装步骤及出现的问题
- 滴滴出行悄然提价 中国打车市场补贴战或将终结
- android 不生成odex文件方法
- 关于AIDL的使用---- Android 进程间通讯之一
- 使用 Struts 2 开发 RESTful 服务
- Android Fragment的生命周期
- go控制语句
- SVM中SMO算法的实现理论+代码