简体   繁体   English

使用Javascript重新定位模态弹出窗口

[英]Re-center Modal Popup with Javascript

I have a modal popup that initially shows some content but expands a div if a checkbox is selected. 我有一个模态弹出窗口,最初显示一些内容,但如果选中了复选框,则展开div。 The modal expands correctly but doesn't recenter unless you scroll up or down. 模态正确扩展,但除非向上或向下滚动,否则不会重新调整。 Is there a javascript event I can tack on to my javascript function to recenter the entire modal? 是否有一个javascript事件我可以使用我的javascript函数来重新定位整个模态?

Here is what it is: 这是它的内容:

$find('ModalPopupExtenderClientID')._layout();

For example: 例如:

$find('detailsPopUpExtenderId')._layout();

and in aspx: 在aspx中:

<ccl:ModalPopupExtender runat="server" ID="MyPopUpExtender" TargetControlID="pop" PopupControlID="PopUp" BehaviorID="detailsPopUpExtenderId" BackgroundCssClass="ModalBackground" />

BehaviorID being the property where to set the clientside id. BehaviorID是设置clientside id的属性。

Be careful that this isn't tied to the resize event of the window. 请注意,这与窗口的resize事件无关。 If it is, your recentering could trigger a resize event in IE, which would cause an infinte loop. 如果是,您的重新定位可能会触发IE中的resize事件,这将导致infinte循环。

If it is tied to the resize event, allow 1 or 2 resize events to occur, but then ignore the rest. 如果它与resize事件绑定,则允许发生1或2个resize事件,但忽略其余事件。 (I say 2, because in IE, a "restore" event on the window will trigger at least 2 resize events (3 in IE6). (我说2,因为在IE中,窗口上的“恢复”事件将触发至少2个调整大小事件(IE6中为3)。

Whatever event you have bound to the scrolling to get it to re-center, bind that event to the checkbox/div expanding event as well (or call it from within the other event). 无论您为了使其重新居中而绑定到滚动的任何事件,都将该事件绑定到checkbox / div展开事件(或者从其他事件中调用它)。 Hard to say more without seeing some code. 没有看到一些代码就很难说更多。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM