Skip to main content
OutSystems

How to resize a pop-up window

Question

How to dynamically resize a pop-up window?

Answer

The pop-up editor grows automatically as needed. To shrink the size of the pop-up window as needed:

  1. Add the Javascript code below to the pop-up.
  2. Call PopupEditor_ForceResize().
function PopupEditor_ForceResize() {
    var popupDiv = window.top.$('.os-internal-ui-dialog-content');
    var popupIframe = window.top.$('.os-internal-ui-dialog-content iframe:first');
    var popupIframeOldHeight = popupIframe.height();
    
    // reduce iframe height to its contents
    popupIframe.height(popupIframe.contents().find('body').height());
    
    // pop-up editor already auto-grows, so we just need to address auto-shrink
    if (popupIframe.height() >= popupIframeOldHeight) {
        return false;
    }

    var result = window.top.RichWidgets_Popup_Editor_resize(popupDiv, -1, -1, false, {target: popupDiv});

    if (!result) {
        // something wrong happened in resize - reset iframe height
        popupIframe.height(popupIframeOldHeight);
    }
}
  • Was this article helpful?