//document.write("
显示框×
"); document.write("
"); document.write("
"); document.write("
"); document.write(" 显示框"); document.write(" ×"); document.write("
"); document.write("
"); document.write(" "); document.write("
"); document.write("
"); document.write("
"); var isie = (document.all) ? true : false; var isie6 = isie && ([/msie (\d+)\.0/i.exec(navigator.useragent)][0][1] == 6); var $g = function (id) { return "string" == typeof id ? document.getelementbyid(id) : id; }; var class = { create: function() { return function() { this.initialize.apply(this, arguments); } } } var extend = function(destination, source) { for (var property in source) { destination[property] = source[property]; } } var bind = function(object, fun) { return function() { return fun.apply(object, arguments); } } var each = function(list, fun){ for (var i = 0, len = list.length; i < len; i++) { fun(list[i], i); } }; var contains = function(a, b){ return a.contains ? a != b && a.contains(b) : !!(a.comparedocumentposition(b) & 16); } var overlay = class.create(); overlay.prototype = { initialize: function(options) { this.setoptions(options); this.lay = $g(this.options.lay) || document.body.insertbefore(document.createelement("div"), document.body.childnodes[0]); this.color = this.options.color; this.opacity = parseint(this.options.opacity); this.zindex = parseint(this.options.zindex); with(this.lay.style){ display = "none"; zindex = this.zindex; left = top = 0; position = "fixed"; width = height = "100%"; } if(isie6){ this.lay.style.position = "absolute"; //ie6设置覆盖层大小程序 this._resize = bind(this, function(){ this.lay.style.width = math.max(document.documentelement.scrollwidth, document.documentelement.clientwidth) + "px"; this.lay.style.height = math.max(document.documentelement.scrollheight, document.documentelement.clientheight) + "px"; }); //遮盖select this.lay.innerhtml = '' } }, //设置默认属性 setoptions: function(options) { this.options = {//默认值 lay: null,//覆盖层对象 color: "#000",//背景色 opacity: 50,//透明度(0-100) zindex: 999999//层叠顺序 }; extend(this.options, options || {}); }, //显示 show: function() { //兼容ie6 if(isie6){ this._resize(); window.attachevent("onresize", this._resize); } //设置样式 with(this.lay.style){ //设置透明度 filter = "alpha(opacity:" + this.opacity + ")"; opacity = this.opacity / 100; backgroundcolor = this.color; display = "block"; } }, //关闭 close: function() { this.lay.style.display = "none"; if(isie6){ window.detachevent("onresize", this._resize); } } }; var lightbox = class.create(); lightbox.prototype = { initialize: function(box, options) { this.box = $g(box);//显示层 this.overlay = new overlay(options);//覆盖层 this.setoptions(options); this.fixed = !!this.options.fixed; this.over = !!this.options.over; this.center = !!this.options.center; this.onshow = this.options.onshow; this.box.style.zindex = this.overlay.zindex + 99990; //this.box.style.display = "none"; //兼容ie6用的属性 if(isie6){ this._top = this._left = 0; this._select = []; this._fixed = bind(this, function(){ this.center ? this.setcenter() : this.setfixed(); }); } }, //设置默认属性 setoptions: function(options) { this.options = {//默认值 over: true,//是否显示覆盖层 fixed: true,//是否固定定位 center: true,//是否居中 onshow: function(){}//显示时执行 }; extend(this.options, options || {}); }, //兼容ie6的固定定位程序 setfixed: function(){ this.box.style.top = document.documentelement.scrolltop - this._top + this.box.offsettop + "px"; this.box.style.left = document.documentelement.scrollleft - this._left + this.box.offsetleft + "px"; this._top = document.documentelement.scrolltop; this._left = document.documentelement.scrollleft; }, //兼容ie6的居中定位程序 setcenter: function(){ this.box.style.margintop = document.documentelement.scrolltop - this.box.offsetheight / 2 + "px"; this.box.style.marginleft = document.documentelement.scrollleft - this.box.offsetwidth / 2 + "px"; }, //显示 show: function(options) { //之前运算到200+px的iframe框时候,会很难看 2017/1/10 //if(parseint(options.height)<300&&parseint(options.width)>800) options.height='500px'; //if(typeof options != 'undefined' && options.width) document.getelementbyid('showiframe').width = options.width; if(typeof options != 'undefined' && options.width){ $("#idbox").css("max-width", options.width);//document.getelementbyid('showiframe').width = options.width; var idboxwidth = $("#idbox").width(); var idboxheight = $("#idbox").height(); $("#idbox").css("margin-left",-idboxwidth/2); $("#idbox").css("margin-top",-idboxheight/2); } if(typeof options != 'undefined' && options.height){ if(parseint(options.height)<($(window).height()-130)) document.getelementbyid('showiframe').height = options.height; else document.getelementbyid('showiframe').height = $(window).height()-130; } //刷新验证码 //getobject('img').src='/has_client/include/code.asp?'+(new date().gettime()); //固定定位 this.box.style.position = this.fixed && !isie6 ? "fixed" : "absolute"; //覆盖层 this.over && this.overlay.show(); this.box.style.display = ""; //document.login_club.username.focus(); //居中 if(this.center){ this.box.style.top = this.box.style.left = "50%"; //设置margin if(this.fixed){ this.box.style.margintop = - this.box.offsetheight / 2 + "px"; this.box.style.marginleft = - this.box.offsetwidth / 2 + "px"; }else{ this.setcenter(); } } //兼容ie6 if(isie6){ if(!this.over){ //没有覆盖层ie6需要把不在box上的select隐藏 this._select.length = 0; each(document.getelementsbytagname("select"), bind(this, function(o){ if(!contains(this.box, o)){ o.style.visibility = "hidden"; this._select.push(o); } })) } //设置显示位置 this.center ? this.setcenter() : this.fixed && this.setfixed(); //设置定位 this.fixed && window.attachevent("onscroll", this._fixed); } this.onshow(); }, //关闭 close: function() { this.box.style.display = "none"; this.overlay.close(); if(isie6){ window.detachevent("onscroll", this._fixed); each(this._select, function(o){ o.style.visibility = "visible"; }); } } }; var box = new lightbox("idbox");