2

I have a iframe placed into a script editor.

When the height of the iframe is set to 100% the images all size correctly but the script editor web part does not.

IFrame Height

How can I get the editor to mach the size of the content inside it?

EDIT: This will resize the iframe to take half of the window size on load. A few tweaks are needed to correct it.

<script type="text/javascript">
        function resize_iframe()
        {
            var height=window.innerWidth;//Firefox
            if (document.body.clientHeight)
            {
                height=document.body.clientHeight;//IE
            }
            //Resize the iframe according to the size of the
            //window (all these should be on the same line)
            document.getElementById("iframe").style.height=parseInt(height-document.getElementById("iframe").offsetTop-8)/2+"px";
        }
        // This will resize the iframe every
        // time you change the size of the window.
        window.onresize=resize_iframe; 
    </script>

1 Answer 1

1

You can add the following javascript code to your master page. It let you manually resize the web parts in edit mode:

$(function() {
    $('div[id^='WebPartWPQ']').resizable({ 
        handles: 'all', 
        autoHide: true
        })
        .find('iframe').height('100%');
});

See this article for more information

2
  • I have tried adding this but will need to find the correct ID as I cant see 'WebPartWPQ' in the HTML. Commented Jan 29, 2016 at 11:23
  • @JamesMichaelLucas I tried this on our own Sharepoint. In edit mode the correct id is: WebPartTitleWPQ7
    – Citizen SP
    Commented Jan 29, 2016 at 12:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.