function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Dynamically Resize iFrame.

I know all about the security restrictions implemented in browsers regarding  cross domain scripting from within an iFrame, but that doesn’t mean this is not possible.  Yes, I have found a method but it would require some help from

If you are lost right now, the idea is simply to have the capability to dynamically resize a iFrame that contains items such as your S-Controls or web page via a URL Tab.  You may have noticed that when the data you are trying to display exceeds the boundaries of the iFrame you then see scroll bars that enable the user to slide the view around so they can see everything.

There is a way through client side scripting to resize the iFrame, but you will get an “Access Denied” message if you attempt to accomplish this resizing via scripting from within your own custom page that is hosted on another domain.

So… After all of that, my first question to pose to this community is:

Is there a current method that allows us as developers to use in order to resize the iFrame?

Second, is anyone else interested in this functionality?

Thirdly, and only if there is no current method for this, would the good people at be willing to hear a possible solution to safely solve this issue and allow us this type of functionality?

Basic Solution:  I bumped into this method in my search to solve this issue, so I can’t take credit for it, but I have tested it and it works.  The cost to SalesForce is an inclusion of a small html page with a small bit of JavaScript that in itself alters the iFrame for you.  It starts out with the iFrame that houses your information.  Then from your web page, you can get the name of the iframe that houses your page in SalesForce.  You then place a small, possibly hidden, iFrame on your web page that links back to the small script page on domain and passes it, via the URL parameters, the main iFrame name/id and the size of your content.  That small script located at, which is in their control, then resizes the main iFrame for you.  This allows you to sidestep the cross domain security issue because the script that modifies the iFrame is also hosted within the same domain.  --  Clear as mud, huh?

 Does any of this make sense?  Hope it was worth my time to post it.

I am all for it.  It's a usability problem in Salesforce.  It impacts custom things as well as many AppExchange applications.  You can post here, but I also suggest you post on  That's where others will vote it up.
Thanks.  I'll give it a shot over there.
Update:  It's Posted.  Thanks again.
For everyone else, the post is at
I'd love to get your code for this.  I'd like to use it on my public knowledge base, which is embedded in an IFRAME on my own website.
I'll try to PM you.  :smileywink:
Thanks.  Although, I think I'll have the same issue, just in reverse of the web tab issue. 

On a domain I own, I am embedding the Salesforce Knowledge Base, which is run on the domain.  Ugh.
Yep... you have to have at least some cooperation between both domains for it to work.  But I sent you the PM anyway. 
I would rather be able to use the knowledge base without an iFrame, and be able to customize the page. The current solution is so out-dated, I was very surprised to find that this is all there is. One way to solve this is for Salesforce to provide a tag language that can be used to access the knowledge base.
There's also another problem... no way to report Solution usage within a certain date range. Or how many Solutions were viewed by a given user. I cannot even add a page tag (such as Google Analytics) to get my own reporting.
How did we get to usage of the knowledge base from a dynamic resize of a Web Tab's iFrame?  Do you use access the knowledge base from within your salesforce instance via a Web Tab?
What we are really talking about here is that the Web Tab setup in salesforce makes you choose a static height.  What some of us would like to see is a method to make the height dynamic so that is automatically changes the height to fit the content.  This would get rid of that pesty secondary vertical scroll bar that appears when the web page inside of the web tab is higher than it was originally specified in the Web Tab Setup.
My bad.
The only time I have ran into this issue is with the public knowledge base feature -- I was researching that issue and came across this post.