+ Start a Discussion

Dynamically change the height of your s-controls

I reckon this might be helpful to a lot of you. If you want to dynamically change the height of an s-control being displayed 'in-line' as part of any page layout, simply call the function below in your s-control after it has loaded (and as needed after anytime the contents of the s-control may change height). Replace ENTER_ID_HERE with the id of the s-control being run.

This same function can be used by s-controls being displayed in a web tab as well, just replace "ENTER_ID_HERE" with "itarget".

function resizeframe(){ 

sframe.style.height=document.body.clientHeight + "px";

Hope this is found helpful.  Happy new year all.


... so text doesn't get cut off when a user changes the window dimensions.
Ron WildRon Wild
You may also want to search for the iframe containing your inline scontrol by it's 'title' value, rather than the element id, so the s-control can be ported from page to page, and across SFDC installations.


         var elements = top.document.getElementsByTagName("iframe");
         for (i=0;i<elements.length;i++)
              if (elements[i].getAttribute("title").substr(0,4) == "your 4 letter prefix" ) {
            elements[i].style.height=(document.body.clientHeight) + "px";