/* 使用方法: $('#smallLay').popdiv( { closeobj: "#pop_til_close",//关闭层对象 isbodybg: true,//是否带背景层 isclose: true,//是否自动关闭弹出层 closetime: 4000,//自动关闭弹出层的时间间隔 isfade:true//是否使用关闭特效 }); */ (function ($) { $.fn.popdiv = function (options) { var defaults = { closeobj: '', isbodybg: true, isclose: false, closetime: 4000, isfade: false, }; var opts = $.extend(defaults, options); var $this = $(this); if (opts.isbodybg) { var new_bodybg = $('
'); new_bodybg.attr({ id: 'bodybg', style: 'width:100%;position:absolute;top:0px;left:0px;z-index:888888888;background:#000;filter:Alpha(opacity=60);opacity:0.6;height:' + $(document).height() + 'px', }); $('body').append(new_bodybg); } // var $html = $('html'); // if ( // $.browser.msie && // $.browser.version == '6.0' && // $html.css('backgroundAttachment') !== 'fixed' // ) { // $html // .css('backgroundAttachment', 'fixed') // .css('backgroundImage', 'url(about:blank)'); // } $this .attr({ style: (style = 'z-index: 9999999999; position: fixed ! important; left: 50%; margin-left: -' + $this.width() / 2 + 'px ! important; top: 50%; margin-top: -' + $this.height() / 2 + 'px ! important;_position:absolute;_top: expression(eval(document.documentElement.scrollTop+(document.documentElement.clientHeight/2)))'), }) .show(); $(opts.closeobj).bind('click', function () { DivClose(); }); if (opts.isclose) { setTimeout(DivClose, opts.closetime); } function DivClose() { if (opts.isfade) { if ($('#bodybg')[0]) { new_bodybg.fadeOut('fast', function () { new_bodybg.remove(); }); } $this.fadeOut(); } else { if ($('#bodybg')[0]) { new_bodybg.remove(); } $this.hide(); } } }; $.fn.closediv = function () { if ($('#bodybg')[0]) { $('#bodybg').remove(); } var $this = $(this); $this.remove(); }; })(jQuery); /* 参数说明:第一个按钮名称、信息、执行的方法 */ function mesgbox(btnName,message,fun) { $(".box_main").empty(); $(".box_main,#bodybg").remove(); var HtmlStr = "
"; HtmlStr += "
温馨提示:关闭
"; HtmlStr += "
"; HtmlStr += "
" + message + "
"; HtmlStr += ""; HtmlStr += "
"; HtmlStr += "
"; HtmlStr += "
"; $("body").append(HtmlStr); $(".box_click").click(function () { fun(); $('.box_main').closediv(); }); $('.box_main').popdiv( { closeobj: ".box_head_close,.box_close", //关闭层对象 isbodybg: true, //是否带背景层 isclose: false, //是否自动关闭弹出层 closetime: 4000, //自动关闭弹出层的时间间隔 isfade: false//是否使用关闭特效 }); }