Home >Backend Development >PHP Tutorial >请教高手帮助解决一个问题!

请教高手帮助解决一个问题!

WBOY
WBOYOriginal
2016-06-23 13:52:09952browse

这段代码是个弹出框,但是弹出后居于页面的上下左右居中,请问如何定位这个弹出框?比如距离顶部100像素。 

function ShowIframe(title,url,w,h)
 {
        var pop=new Popup({ contentType:1,scrollType:'no',isReloadOnClose:false,width:w,height:h});
        pop.setContent("contentUrl",url);
        pop.setContent("title",title);
    
        pop.build();
        pop.show();
         }



 上传图片



回复讨论(解决方案)

popup是什么 看样子是某种js插件?
如果是,百度一下应该有使用方法文档的

popup是什么 看样子是某种js插件?
如果是,百度一下应该有使用方法文档的



搜过了,没有找到解决的办法

贴出 Popup 的定义

///******************* popup.js********************/
///修正ie5、ie6、ie7、firefox3.0 兼容问题
///************************************************/
if(!Array.prototype.push){Array.prototype.push=function(){var startLength=this.length;for(var j=0;j';var cB='filter: alpha(opacity='+this.info.coverOpacity+');opacity:'+this.info.coverOpacity/100+';';var cover='

接上楼

style="position:absolute;top:0px;left:0px;width:100%;height:100%;z-index:'+baseZIndex+';'+cB+'background-color:'+this.color.cColor+';display:none;">

';var mainBox='
';if(this.config.isHaveTitle){mainBox+=''}else{mainBox+=''};mainBox+='
'+''+'
'+this.info.title+' '+close+'
'+close+'
'+'
';if(!this.config.isBackgroundCanClick){G('dialogCase').innerHTML=cover+mainBox;this.setBackgroundSize();window.onresize=this.setBackgroundSize;}else{G('dialogCase').innerHTML=mainBox;}Event.observe(G('dialogBoxClose'),"click",this.reset.bindAsEventListener(this),false);if(this.config.isSupportDraging){dropClass=new Dragdrop(this.config.width,this.config.height,this.info.shadowWidth,this.config.isSupportDraging,this.config.contentType);G("dialogBoxTitle").style.cursor="move"};this.lastBuild()},setBackgroundSize:function(){var getValueWidth;var getMaxValueWidth=[getValue("clientWidth"),getValue("scrollWidth")];getValueWidth=eval("Math.max("+getMaxValueWidth.toString()+")");G('dialogBoxBG').style.width=getValueWidth;var getValueHeight;var getMaxValueHeight=[getValue("clientHeight"),getValue("scrollHeight")];getValueHeight=eval("Math.max("+getMaxValueHeight.toString()+")");G('dialogBoxBG').style.height=getValueHeight;},lastBuild:function(){var confirm='
'+this.info.confirmCon+'
 
';var alert='
'+this.info.alertCon+'
';var baseZIndex=10001+this.info.overlay*10;var coverIfZIndex=baseZIndex+4;if(this.config.contentType==1){var openIframe="";var coverIframe="
";G("dialogBody").innerHTML=openIframe+coverIframe;}else if(this.config.contentType==2){G("dialogBody").innerHTML=this.info.contentHtml;}else if(this.config.contentType==3){G("dialogBody").innerHTML=confirm;Event.observe(G('dialogOk'),"click",this.forCallback.bindAsEventListener(this),false);Event.observe(G('dialogCancel'),"click",this.close.bindAsEventListener(this),false);}else if(this.config.contentType==4){G("dialogBody").innerHTML=alert;Event.observe(G('dialogYES'),"click",this.close.bindAsEventListener(this),false);};},reBuild:function(){G('dialogBody').height=G('dialogBody').clientHeight;this.lastBuild()},show:function(){this.hiddenSome();this.middle();if(this.config.isShowShadow)this.shadow()},forCallback:function(){return this.info.callBack(this.info.parameter)},shadow:function(){var oShadow=G('dialogBoxShadow');var oDialog=G('dialogBox');oShadow['style']['position']="absolute";oShadow['style']['background']="#000";oShadow['style']['display']="";oShadow['style']['opacity']="0.2";oShadow['style']['filter']="alpha(opacity=20)";oShadow['style']['top']=oDialog.offsetTop+this.info.shadowWidth+"px";oShadow['style']['left']=oDialog.offsetLeft+this.info.shadowWidth+"px";oShadow['style']['width']=oDialog.offsetWidth+"px";oShadow['style']['height']=oDialog.offsetHeight+"px";},middle:function(){if(!this.config.isBackgroundCanClick)G('dialogBoxBG').style.display='';var oDialog=G('dialogBox');oDialog['style']['position']="absolute";oDialog['style']['display']='';var sClientWidth=getValue("clientWidth");var sClientHeight=getValue("clientHeight");var sScrollTop=getValue("scrollTop");var sleft=(sClientWidth/2)-(oDialog.offsetWidth/2);var iTop=(sClientHeight/2+sScrollTop)-(oDialog.offsetHeight/2);var sTop=iTop>0?iTop:(sClientHeight/2+sScrollTop)-(oDialog.offsetHeight/2);if(sTop

接上楼

parseInt(this.oObj.style.top)+25)iTop=iTop+12;this.oObj.style.left=iLeft+"px";this.oObj.style.top=iTop+"px";;if(this.showShadow){G('dialogBoxShadow').style.left=iLeft+this.shadowWidth+"px";G('dialogBoxShadow').style.top=iTop+this.shadowWidth+"px";};this.dragData={x:Event.pointerX(event),y:Event.pointerY(event)};document.body.style.cursor="move";},mouseup:function(event){if(!this.IsDraging)return;if(this.contentType==1)G("iframeBG").style.display="none";document.onmousemove=null;document.onmouseup=null;var mousX=Event.pointerX(event)-(document.documentElement.scrollLeft||document.body.scrollLeft);var mousY=Event.pointerY(event)-(document.documentElement.scrollTop||document.body.scrollTop);var oObjBottom;var oObjRight;if(this.showShadow){oObjBottom=parseInt(this.oObj.style.top)+this.height+this.shadowWidth;oObjRight=parseInt(this.oObj.style.left)+this.width+this.shadowWidth;}else{oObjBottom=parseInt(this.oObj.style.top)+this.height;oObjRight=parseInt(this.oObj.style.left)+this.width;};if(mousXdocument.body.clientWidth||mousY>document.body.clientHeight||parseInt(this.oObj.style.left)document.body.clientWidth||oObjBottom>document.body.clientHeight){this.oObj.style.left=this.backData["x"];this.oObj.style.top=this.backData["y"];if(this.showShadow){G('dialogBoxShadow').style.left=this.backData.x+this.shadowWidth;G('dialogBoxShadow').style.top=this.backData.y+this.shadowWidth;};};this.IsDraging=false;document.body.style.cursor="";Event.stopObserving(document,"selectstart",this.returnFalse,false);},returnFalse:function(){return false;}};function openshow(url,title,w,h,stype){g_pop=new Popup({contentType:stype,isReloadOnClose:false,width:w,height:h});g_pop.setContent("title",title);g_pop.setContent("contentUrl",url);g_pop.build();g_pop.show();}function g_close_pop_re(){g_pop.close();location.reload();}function Comment(url,w,h){g_pop=new Popup({contentType:1,isReloadOnClose:false,width:w,height:h});g_pop.setContent("title","登陆");g_pop.setContent("scrollType","no");g_pop.setContent("contentUrl",url);g_pop.build();g_pop.show();}function g_close_pop(){g_pop.close();g_pop=null;}function ShowAlert(title,content,w,h){var pop=new Popup({contentType:4,isReloadOnClose:false,width:w,height:h});pop.setContent("title",title);pop.setContent("alertCon",content);pop.build();pop.show();}function Wclose(){g_pop.close();g_pop=null;}

直接用Chrome等浏览器的开发者工具来查看Popup生成的HTML,然后直接定义相应的CSS样式就行了。

直接用Chrome等浏览器的开发者工具来查看Popup生成的HTML,然后直接定义相应的CSS样式就行了。


当然,这是暴力方法,但绝对有效。可能Popup插件本身就有定位的方法,但是懒得去研究查找。

那么多Popup插件,没文档不知道换一个插件么?

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn