Dynamically Resize SharePoint Modal Dialogs

My colleague Alec and I ran into an issue today where SharePoint was having difficulty rendering modal dialogs at the correct size. The dialogs were too small for the content they contained, and therefore some undesired scroll bars appeared. Nobody wants that!

Thanks to Chad Schroeder’s post for a nifty little fix:

function resizeDLG() {
var dlg = SP.UI.ModalDialog.get_childDialog();
if (dlg != null) {
dlg.autoSize();
}
}
setTimeout(resizeDLG, 500);

Add that to your Master Page and tweak as necessary for your purposes, and when SharePoint loads a page as a dialog it should size itself properly.

4 responses to “Dynamically Resize SharePoint Modal Dialogs

  1. This is exactly what I’m looking for, but I’m not really sure where to put it. Can it go in my custom page layout? And if it has to go in the master page, where inside the master page does it go?

    Also, is the 500 in the script the size it will change to?

    Thanks!

  2. Thank you very much!

    I was experiencing the very same bug on my Company’s sharepoint2013 and this script worked like a charm.

  3. Can you please give me step by step instructions as to where to place the text. I tried adding the text to the script editor to no avail. I went to edit the Home.aspx page but not sure where and what tags if any are needed. I am new to this but really want to figure out how to make the dialog box resize to the content when I click on a promoted link in sharepoint. Thank you and I look forward to hearing back soon.

    Loren

Comments are closed.