請教高手協助解決一個問題!

來源:互聯網
上載者:User
這段代碼是個彈出框,但是彈出後居於頁面的上下左右置中,請問如何定位這個彈出框?比如距離頂部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<1)sTop="20";if(sleft<1)sleft="20";oDialog['style']['left']=sleft+"px";oDialog['style']['top']=sTop+"px";},reset:function(){if(this.config.isReloadOnClose){top.location.reload();};this.close();},close:function(){G('dialogBox').style.display='none';if(!this.config.isBackgroundCanClick)G('dialogBoxBG').style.display='none';if(this.config.isShowShadow)G('dialogBoxShadow').style.display='none';G('dialogBody').innerHTML='';this.showSome();},hiddenSome:function(){var tag=this.info.someHiddenTag.split(",");if(tag.length==1&&tag[0]==""){tag.length=0;}for(var j=0;j

接上樓

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(mousX<1||mousY<1||mousX>document.body.clientWidth||mousY>document.body.clientHeight||parseInt(this.oObj.style.left)<0||parseInt(this.oObj.style.top)<0||oObjRight>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外掛程式,沒文檔不知道換一個外掛程式嗎?

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.