博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
弹出窗口插件
阅读量:6223 次
发布时间:2019-06-21

本文共 8090 字,大约阅读时间需要 26 分钟。

弹出透明遮罩窗口插件,兼容性强,界面友好!

曾祥展  弹出透明遮罩窗口
调用:

Html:

提示

 
/*弹出窗口插件*/   
(function($){    $.fn.dialog=function(flag,options){        var opts = $.extend({}, $.fn.dialog.options, options);        var popDiv = this;          if(flag=="close" && popDiv.is(":visible")){            if(popDiv.data("popWarp")){                popDiv.data("popWarp").remove();            }            popDiv.hide();            return;        }        var maxH = $(document).height()+"px";        var maxW = $(window).width()+"px";        var winX = ($(window).width()- popDiv.width())/2 + "px";        var winY = ($(window).height()- popDiv.height())/2 + $(window).scrollTop() + "px";        var popWarp=$("
").addClass(opts.popWarp); if(flag=="open" && popDiv.is(":hidden")){ popDiv.data("popWarp",popWarp); popDiv.after(popWarp); popWarp.css({width:maxW,height:maxH,left:"0px",top:"0px","z-index":opts.zindex}); popDiv.css({left:winX,top:winY,"z-index":(opts.zindex+1)}); popDiv.show(); } $(window).resize(function(){ var maxH = $(document).height()+"px"; var maxW = $(window).width()+"px"; var winX = ($(window).width()- popDiv.width())/2 + "px"; var winY = ($(window).height()- popDiv.height())/2 + $(window).scrollTop() + "px"; popDiv.css({left:winX,top:winY}); popWarp.css({width:maxW,height:maxH,left:"0px",top:"0px"}); }); $(opts.closeWin).click(function(){ if(popDiv.data("popWarp")){ popDiv.data("popWarp").remove(); } popDiv.hide(); try{ if (objfocus) { objfocus.focus(); } }catch (e){ } }); //判断是否需要滚动; var con={ scrol:function(kg){ if(kg!="off"){ $(window).bind("scroll.popWin"+popDiv.attr("id"),function (){ var offsetTop = ($(window).height()- popDiv.height())/2 + $(window).scrollTop() +"px"; popDiv.animate({top : offsetTop },{duration:380 , queue:false }); }); }else{ $(window).unbind("scroll.popWin"+popDiv.attr("id")); } } }; con.scrol(""); return con; }; $.fn.dialog.options={ closeWin:".closeWin", popWarp:"popWarp", zindex:999 }; $.fn.popWin=function(closeId,scrolls){ var popDiv = this; var maxH = $(document).height()+"px"; var maxW = $(window).width()+"px"; var winX = ($(window).width()- popDiv.width())/2 + "px"; var winY = ($(window).height()- popDiv.height())/2 + $(window).scrollTop() + "px"; this.after("
"); $(".popWarp").css({width:maxW,height:maxH,left:"0px",top:"0px"}); popDiv.css({left:winX,top:winY}); popDiv.show(); $(window).resize(function(){ var maxH = $(document).height()+"px"; var maxW = $(window).width()+"px"; var winX = ($(window).width()- popDiv.width())/2 + "px"; var winY = ($(window).height()- popDiv.height())/2 + $(window).scrollTop() + "px"; popDiv.css({left:winX,top:winY}); $(".popWarp").css({width:maxW,height:maxH,left:"0px",top:"0px"}); }); popDiv.find(closeId).click(function(){ $('#dialog1').dialog('close'); $(".popWarp").remove(); popDiv.hide(); }); //判断是否需要滚动; if(scrolls){ var menuYloc = popDiv.offset().top; $(window).scroll(function (){ var offsetTop = ($(window).height()- popDiv.height())/2 + $(window).scrollTop() +"px"; popDiv.animate({top : offsetTop },{duration:380 , queue:false }); }); } }; $.fn.fileLoad=function(flag,options){ var opts = $.extend({}, $.fn.dialog.options, options); var popDiv = this; if(flag=="close" && popDiv.is(":visible")){ if(popDiv.data("popWarp")){ popDiv.data("popWarp").remove(); } var div = document.getElementById("fileLoad"); div.style.display = "none"; popDiv.hide(); $(".popWarp").hide(); return; } if(flag=="open"){ popDiv.show(); } $(window).resize(function(){ var maxH = $(document).height()+"px"; var maxW = $(window).width()+"px"; var winX = ($(window).width()- popDiv.width())/2 + "px"; var winY = ($(window).height()- popDiv.height())/2 + $(window).scrollTop() + "px"; popDiv.css({left:winX,top:winY}); popWarp.css({width:maxW,height:maxH,left:"0px",top:"0px"}); }); $(opts.closeWin).click(function(){ if(popDiv.data("popWarp")){ popDiv.data("popWarp").remove(); } popDiv.hide(); try{ if (objfocus) { objfocus.focus(); } }catch (e){ } }); //判断是否需要滚动; var con={ scrol:function(kg){ if(kg!="off"){ $(window).bind("scroll.popWin"+popDiv.attr("id"),function (){ var offsetTop = ($(window).height()- popDiv.height())/2 + $(window).scrollTop() +"px"; popDiv.animate({top : offsetTop },{duration:380 , queue:false }); }); }else{ $(window).unbind("scroll.popWin"+popDiv.attr("id")); } } }; con.scrol(""); return con; }; })(jQuery);
 
 
 
/*基本信息*/body{ font-family:"宋体"; font-size:12px; margin:0px; padding:0px; color:#333333;background:#fff;}div,ul,li,h1,h2,h3,h4,h5.h6,img,p,dl,dt,dd,ol,th,td{ margin:0px; padding:0px;}li{ list-style-type:none;}form,input,button,option,textarea,select{ margin:0px; padding:0px;}input,button,option,textarea,select{ font:100% Tahoma,Helvetica,Arial,sans-serif;}textarea{ resize: none;}a{ color:#333333; text-decoration:none;}a:link{ text-decoration:none;}a:visited{ text-decoration:none;}a:hover{ text-decoration:underline;}a:active{ text-decoration:none;}table{ font-size:inherit; font:100%;}th{ font-weight:bold;}img{ border:0px;}h3{ font-size:14px; color:#000;}h4{ font-size:12px;}.clear{ clear:both; height:0px; overflow:hidden;}.section{ width:100%; clear:both;}.column{ width:100%; clear:both; overflow:hidden;}.field{ width:100%; clear:both; overflow:hidden;}/* for Firefox 去除虚线框 */input[type=submit]::-moz-focus-inner,input[type=button]::-moz-focus-inner{  border : 0px;}/* for IE8 去除虚线框 */input[type=submit]:focus, input[type=button]:focus{    outline : none;}/*弹出窗口全局样式*/.popWarp{
background:#111;-moz-opacity: 0.5;opacity:0.5;filter: alpha(opacity=50);position:absolute;z-index:1200;}.popWin{
display:none; width:415px; background:#E4E4E4; padding:5px; position:absolute; left:40%; top:20%; z-index:1280;}.popWin .popbox{ background:#fff; border:#C4C4C4 1px solid; padding:0 4px 13px 4px;}.popWin .popbox h3{ height:36px; border-bottom:#47B030 1px solid; font-size:14px; line-height:36px; padding:0 8px; color:#000;background: #fff;}.popWin .popbox h3 b{ float:left;}.popWin .popbox h3 span{ float:right; font-weight:100; cursor:pointer;}.popWin .popbox ul{ padding:44px 0 10px 67px;}.popWin .popbox ul li{ margin-bottom:16px;}.popWin .popbox ul li span{ line-height:25px; float:left; display:block;}.popWin .popbox ul li input{ width:151px; height:20px; border:#8E9BA3 1px solid; line-height:20px;}.popWin .popbox ul li.button{ padding:36px 15px 0 0;}.popWin .popbox ul li.button input{ width:78px; height:28px; background:#87BC48; border:#4D8B02 1px solid; float:right; color:#fff; font-size:14px; cursor:pointer; margin-right:15px;}
 
 

转载于:https://www.cnblogs.com/zengxiangzhan/archive/2012/01/14/2322172.html

你可能感兴趣的文章
一次马失前蹄的SQL优化:递归查询引发的血案
查看>>
《HBase实战》一第一部分 HBase基础
查看>>
《触摸屏游戏设计》——导读
查看>>
《OpenGL超级宝典(第5版)》——第1章,第1.2节3D图形技术和术语
查看>>
如何让你的机器学习玩超级玛丽
查看>>
阿里NASA计划“亮剑”:谢崇进和他追求的科学极限
查看>>
docker 基本命令 (CentOs7 Docker 17.03.1-ce)
查看>>
Apache Spark源码走读(八)Graphx实现剖析&spark repl实现详解
查看>>
PostgreSQL 10.0 preview sharding增强 - 支持分布式事务
查看>>
DDD领域驱动设计 - 设计文档模板
查看>>
架构师速成7.3-devops为什么很重要
查看>>
数据库事务
查看>>
使用API网关建立多场景测试环境
查看>>
妹子们选择程序媛作为职业是一种怎样的体验?
查看>>
PgSQL · 源码分析 · PG优化器物理查询优化
查看>>
玩转云镜像制作之packer篇
查看>>
程序员面试金典算法题
查看>>
[sharepoint]Rest api相关知识(转)
查看>>
Cocos2d-x3.2单点触摸
查看>>
MongoDB-3.2 oplog删除策略优化
查看>>