jQuery弹出窗口完整代码
2015-01-08 14:56
393 查看
参考: http://www.cnblogs.com/jihua/archive/2012/10/08/2715175.html,
另外一个类似的, 带步骤确认的窗口:http://keleyi.com/keleyi/phtml/jquery/1.htm
另外一个类似的, 带步骤确认的窗口:http://keleyi.com/keleyi/phtml/jquery/1.htm
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>jQuery弹出窗口</title> <style type="text/css"> .window{ width:400px; background-color:#d0def0; position:absolute; padding:2px; margin:5px; display:none; } .content{ height:200px; background-color:#FFF; font-size:14px; overflow:auto; } .win_title{ padding:2px; color:#0CF; font-size:14px; } .win_title img{ float:right; } </style> <script type="text/javascript" src="http://s0.qhimg.com/lib/jquery/183.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="win_title"><img src="http://pic002.cnblogs.com/images/2012/451207/2012100814082487.jpg" alt="关闭" />窗口标题 - center</div> <div class="content">www.google.cn</div> </div> <div class="window" id="left"> <div id="title2" class="win_title"><img src="http://pic002.cnblogs.com/images/2012/451207/2012100814082487.jpg" alt="关闭" />窗口标题 - left</div> <div class="content">www.baidu.com</div> </div> <div class="window" id="right"> <div id="title3" class="win_title"><img src="http://pic002.cnblogs.com/images/2012/451207/2012100814082487.jpg" alt="关闭" />窗口标题 - right</div> <div class="content">www.qq.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(){ $(".win_title img").click(function(){ $(this).parent().parent().hide("normal"); }); } function popCenterWindow(){ init(); //计算弹出窗口的左上角Y的偏移量 var popY=(windowHeight-popHeight)/2; //垂直方向偏移量 var popX=(windowWidth-popWidth)/2; //水平方向偏移量 //设定窗口的位置 $("#center").css("top",popY).css("left",popX).slideToggle("fast"); closeWindow(); } function popLeftWindow(){ init(); //计算弹出窗口的左上角Y的偏移量 var popY=windowHeight-popHeight; //var popX=-(windowWidth-popWidth); //设定窗口的位置 $("#left").css("top",popY-50).css("left",50).slideToggle("slow"); closeWindow(); } function popRightWindow() { init(); //计算弹出窗口的左上角Y的偏移量 var popY=windowHeight-popHeight; var popX=windowWidth-popWidth; //设定窗口的位置 $("#right").css("top",popY-50).css("left",popX-50).slideToggle("normal"); closeWindow(); } </script> </body> </html>
相关文章推荐
- jQuery弹出窗口完整代码
- jQuery弹出窗口完整代码(居中,居左,居右)
- jQuery弹出窗口完整代码(居中,居左,居右)
- jQuery弹出窗口完整代码
- jQuery弹出窗口完整代码
- jquery实现弹出窗口效果的实例代码
- jQuery 右下角滑动弹出可关闭重现层完整代码
- jquery 弹出登录窗口实现代码
- jQuery弹出窗口简单实现代码
- jQuery+jqmodal弹出窗口实现代码分明
- jQuery实现右下角滑动弹出可关闭重现层完整代码
- jquery 弹出一个淡出窗口示例代码
- jQuery实现弹出窗口弹出div层的实例代码
- jQuery+jqmodal弹出窗口实现代码分明
- jQuery弹出窗口打开链接的实现代码
- jquery实现弹出窗口效果的实例代码
- jQuery 右下角滑动弹出可关闭重现层完整代码
- jquery实现弹出窗口效果的实例代码
- jquery 弹出登录窗口实现代码
- Jquery教程:JS弹出窗口DIV层效果代码