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 });
  • 相关阅读:
    【python】第一个爬虫:用requests库爬取网页内容
    【python】UDP协议编程
    【python】体育竞技分析:预测球队比赛成绩
    【python】手绘图制作
    【python】成绩表雷达图
    【python】numpy库和matplotlib库学习笔记
    【python】PIL库之图片处理
    【python】PIL库学习总结
    【python】利用jieba中文分词进行词频统计及生成词云
    汉诺塔问题
  • 原文地址:https://www.cnblogs.com/baily/p/3807854.html
Copyright © 2011-2022 走看看