function pop(title, content,width) { this.params={}; this.win = window.top; var html = '
'; html += '
'; html += '
'; html += '
' + title; html += '
'; if(content) { html += '
' + content + '
'; } html += '

'; html += '
'; this.jqContent =this.win.$(html); //$(this.win.document.body).append(this.jqContent); this.jqContent.appendTo(this.win.document.body); this.jqContent.find(".popTit>.colseBtn").click(function() { this.hide(); }.bind(this)); if(width) { this.jqContent.find(".popBox").css("width",width+"px"); } } pop.prototype.hide=function(){ this.jqContent.hide(); this.win.onPopScroll=false; }; pop.prototype.show=function(){ this.win.onPopScroll= this.toCenter.bind(this); if(!this.win.hasAddPopScroll) { this.win.hasAddPopScroll=true; var oldonscroll = this.win.onscroll; if(typeof oldonscroll != 'function') { this.win.onscroll = function(){ if(window.onPopScroll) { window.onPopScroll(); } }; } else { this.win.onscroll = function(){ oldonscroll.apply(this,arguments); if(window.onPopScroll) { window.onPopScroll(); } }; } } this.jqContent.show(); this.toCenter(); }; pop.prototype.close=function(){ this.win.onPopScroll=false; this.jqContent.remove(); this.win.onPopScroll=null; }; pop.prototype.open=function(){ this.jqContent.appendTo(this.win.document); this.show(); }; pop.prototype.destroy=function(){ delete this.jqContent; //在ie下会报错,价格try算了 try{ delete this; } catch(e){} }; pop.prototype.addButton=function(btnName,click){ this.win.$('') .appendTo(this.jqContent.find(".btn_list")) .click(click).get(0).pop=this; }; pop.prototype.toCenter=function(){ var doc=this.win.document; var mod=this.jqContent.get(0); var pop=this.jqContent.find('.popBox').get(0); var documentHeight=doc.documentElement.scrollHeight; mod.style.width = doc.documentElement.scrollWidth + "px"; mod.style.height = documentHeight + "px"; if(!-[1,]) { var filter=this.findByJQ(".filter").get(0); filter.style.height = documentHeight+"px"; } pop.style.left = (doc.documentElement.scrollLeft + (doc.documentElement.clientWidth - pop.offsetWidth) / 2) + "px";//左右居中 var T=0; if(doc.documentElement.clientHeight-pop.offsetHeight>0) { T = doc.documentElement.scrollTop+(doc.documentElement.clientHeight-pop.offsetHeight)/2;//上下居中 } pop.style.top=doc.body.scrollTop+T+'px'; }; pop.prototype.findByJQ=function(select) { return this.jqContent.find(select); }; pop.prototype.setOuterParam=function(name,value) { if(!this.params) { this.params={}; } this.params[name]=value; }; pop.prototype.getOuterParam=function(name) { return this.params[name]; };