zoukankan      html  css  js  c++  java
  • jQuery 弹出层脚本

    直接贴代码:

     1 $.extend({
     2     closeBox: function (o, x, fn) {
     3         $('#' + o).fadeOut(500, function () {
     4             if (fn && typeof (fn) === "function") { fn(); }
     5         });
     6         if ($('#v_overlay')[0]) { $('#v_overlay').fadeOut(650, function () { $(this).remove(); }); }
     7     },
     8     openBox: function (o, x, fn) {
     9         $.init(o, x, fn); $('#' + o).fadeIn(500);
    10     },
    11     init: function (o, x, fn) {
    12         var w = $(window).width(), h = $(window).height();
    13         var bw = $("#" + o).width(), bh = $("#" + o).height();
    14         var _top = ((h / 2 - bh / 2) - 50);
    15         var boxCss = { "left": ((w / 2 - bw / 2) + "px"), "top": ((_top > 0 ? _top : 10) + "px"), "z-index": "999", "position": "fixed" };
    16         $("#" + o).css(boxCss);
    17         try {
    18             if ($.browser.msie && ($.browser.version == "6.0") && !$.support.style) {
    19                 $("#" + o).css("position", "absolute"); location.href = location.href.search(/?/) > 0 ? location.href.substring(0, location.href.indexOf('#')) : location.href + "#";
    20             }
    21             if ((window.innerHeight - 40) <= $("#" + o).height()) {
    22                 $("#" + o).css({ "position": "absolute", "top": (40 + window.scrollY) });
    23             }
    24         } catch (e) { }
    25         if (x != undefined && $("body").find("#v_overlay").html() == null) {
    26             var boxBg = "<div id="v_overlay" style="position:absolute;background-color:#000;filter:alpha(opacity=30);opacity:0.3;100%;left:0;top:0;z-index:998;border:none;display:none"></div>";
    27             $(boxBg).click(function () { $.closeBox(o, x); }).height($(document).height()).appendTo("body").fadeIn();
    28         }
    29         $(window).resize(function () {
    30             if ($("#" + o).css("display") == "block") {
    31                 $('#v_overlay').remove(); $.init(o, x);
    32             }
    33         });
    34     }
    35 });
  • 相关阅读:
    通讯录封装实现
    简单通讯录的实现 main..h .m文件全部
    iOS 开发 OC编程 字典和集合 排序方法
    iOS 开发 OC编程 数组冒泡排序.图书管理
    iOS 开发 OC编程 属性和字符串练习
    iOS 开发 OC编程 属性和字符串
    iOS 开发 OC编程 便利构造器以及初始化方法
    iOS 开发 OC编程 方法的书写
    IOS 开发 OC编程 类和对象
    iOS 开发 c语言阶段考试题
  • 原文地址:https://www.cnblogs.com/baily/p/3807854.html
Copyright © 2011-2022 走看看