直接贴代码:

 $.extend({
closeBox: function (o, x, fn) {
$('#' + o).fadeOut(500, function () {
if (fn && typeof (fn) === "function") { fn(); }
});
if ($('#v_overlay')[0]) { $('#v_overlay').fadeOut(650, function () { $(this).remove(); }); }
},
openBox: function (o, x, fn) {
$.init(o, x, fn); $('#' + o).fadeIn(500);
},
init: function (o, x, fn) {
var w = $(window).width(), h = $(window).height();
var bw = $("#" + o).width(), bh = $("#" + o).height();
var _top = ((h / 2 - bh / 2) - 50);
var boxCss = { "left": ((w / 2 - bw / 2) + "px"), "top": ((_top > 0 ? _top : 10) + "px"), "z-index": "999", "position": "fixed" };
$("#" + o).css(boxCss);
try {
if ($.browser.msie && ($.browser.version == "6.0") && !$.support.style) {
$("#" + o).css("position", "absolute"); location.href = location.href.search(/\?/) > 0 ? location.href.substring(0, location.href.indexOf('#')) : location.href + "#";
}
if ((window.innerHeight - 40) <= $("#" + o).height()) {
$("#" + o).css({ "position": "absolute", "top": (40 + window.scrollY) });
}
} catch (e) { }
if (x != undefined && $("body").find("#v_overlay").html() == null) {
var boxBg = "<div id=\"v_overlay\" style=\"position:absolute;background-color:#000;filter:alpha(opacity=30);opacity:0.3;width:100%;left:0;top:0;z-index:998;border:none;display:none\"></div>";
$(boxBg).click(function () { $.closeBox(o, x); }).height($(document).height()).appendTo("body").fadeIn();
}
$(window).resize(function () {
if ($("#" + o).css("display") == "block") {
$('#v_overlay').remove(); $.init(o, x);
}
});
}
});

jQuery 弹出层脚本的更多相关文章

  1. JQuery弹出层,实现弹层切换,可显示可隐藏。

    <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <t ...

  2. JQuery弹出层,点击按钮后弹出遮罩层,有关闭按钮

    <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <t ...

  3. JQuery弹出层,点击按钮后弹出遮罩层,有关闭按钮【转】

    <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <t ...

  4. 基于jQuery弹出层图片动画查看代码

    分享一款基于jQuery弹出层图片动画查看代码是一款鼠标单击文字或图片内容放大显示且含圆角投影效果.效果图如下: 在线预览   源码下载 实现的代码. html代码: <div class=&q ...

  5. 【jquery】fancybox 是一款优秀的 jquery 弹出层展示插件

    今天给大家分享一款优秀的 jquery 弹出层展示插件 fancybox.它除了能够展示图片之外,还可以展示 flash.iframe 内容.html 文本以及 ajax 调用,我们可以通过 css ...

  6. jQuery弹出层效果

    <!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head><meta ...

  7. 效果非常好的 Jquery弹出层插件 jQuery Sweet alert

    介绍款交互性非常不错的jquery弹出层插件,支持消息提示.错误提示.确认框提示等. 交互式体验感非常不错,比如咱们现在体验非常不错的微信支付.支付宝等完成后的效果. 不过本插件至少支持IE9+ Jq ...

  8. jQuery弹出层插件popbox

    都什么年代了,还自己写弹出层插件!是的,①自己写的自己好控制②可定制性高③兼容低版本IE 本插件有以下特性: 样式分离,可定制,纯净无图片 可自定义按钮及按钮的样式.点击事件 可指定选择器选择页面元素 ...

  9. jQuery弹出层始终垂直居中相对于屏幕或当前窗口

    把弹出层的位置设为fixed,设置top:50%,然后获取当前元素的整体的高度height,用获取的高度height/2,设置margin-top:-height/2.即可把当前的弹出层始终垂直居中于 ...

随机推荐

  1. 关于smarty的一些个人笔记

    注释为{注释} 注意下面代码中<%extends file="路径"%>和<%widget name="路径"%>这两个路径中的区别 c ...

  2. status bar、navigationBar、tableView吸顶view设置

    1. 隐藏navigationBar self.navigationController.navigationBar.hidden = YES; 2. status bar设置 -(void)view ...

  3. Bittorrent Protocol Specification v1.0 中文

    翻译:小马哥 日期:2004-5-22 BitTorrent 是一种分发文件的协议.它通过URL来识别内容,并且可以无缝的和web进行交互.它基于HTTP协议,它的优势是:如果有多个下载者并发的下载同 ...

  4. "mkimage" command not found - U-Boot images will not be built

    编译内核的时候出现错误:"mkimage" command not found - U-Boot images will not be built 参考链接 http://blog ...

  5. centos7最小安装后常常需要添加的命令

    本人下载的最小镜像文件下载地址:http://pan.baidu.com/s/1kUD2jbT 原文地址:http://blog.csdn.net/nmgrd/article/details/5176 ...

  6. Python之路----------迭代器

    直接用作于for循环的数据类型有以下几种: 1.集合类的数据类型:list tuple dict set str等 2.生成器generator,包括生成器和带有yiled 的generator fu ...

  7. c++中vector的用法详解

    c++中vector的用法详解 vector(向量): C++中的一种数据结构,确切的说是一个类.它相当于一个动态的数组,当程序员无法知道自己需要的数组的规模多大时,用其来解决问题可以达到最大节约空间 ...

  8. SqlServer try catch 捕获不到的一些错误及解决方法(转载)

    测试注意 :①假如系统能捕获异常 ,并且我们自己开启了事务.系统会自动 回滚事务的,但是 我们还是要在catch里面加上 rollback tran的习惯,这样也不会提示重复rollback的错误,这 ...

  9. APP开发:对于IOS APP应用的推广渠道有哪些?

    亿合科技了解到,随着移动互联网时代的到来,苹果从2007年进入中国市场,一直备受大众喜爱,手机应用也层出不穷.那么对于那么多的IOS APP应用怎么能获得用户的喜爱呢?于是推广APP应用是需要做的,亿 ...

  10. JSP基本语法小结

    jsp表达式:<%=???%> 在jsp页面嵌入java代码<%Java代码%>可以用多个<% %>分割代码段 jsp声明:<%!用这样的方法可以声明java ...