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
TehNrdTehNrd 

Are inline visualforce pages now served from the same domain?

One of the largest pain points with inline visualforce pages is that the height is static even though the content may be dynamic. The response from salesforce.com has been:

"As for iframes, they do not provide a "dynamic height" capability natively. If the domain of the page that served the iframe is the same as that of the page that is embedded in the iframe then you can write script that resizes the frame to fit the contents but this is something that is not possible for Visualforce pages since they are now served from force.com."

Well....I tried this and it now works. I added this inline page to a layout and in the settings set the height to 15px. Once loaded it dynamically adjusts the height based on the content. So far I have tested with FF3 and IE6, works on both.

<apex:page standardcontroller="Opportunity">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's
standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make
a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting,
remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing
Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions
of Lorem Ipsum. Why do we use it? It is a long established fact that a reader will be distracted by the readable
content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal
distribution of letters, as opposed to using 'Content here, content here', making it look like readable English.
Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search
for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years,
sometimes by accident, sometimes on purpose (injected humour and the like).Where does it come from? Contrary to popular
belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making
it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of
the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical
literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum
et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics,
very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in
section 1.10.32. The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections
1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form,
accompanied by English versions from the 1914 translation by H. Rackham. Where can I get some? There are many variations
of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised
words which don't look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there
isn't anything embarrassing hidden in the middle of text. All the Lorem Ipsum generators on the Internet tend to repeat
predefined chunks as necessary, making this the first true generator on the Internet. It uses a dictionary of over 200
Latin words, combined with a handful of model sentence structures, to generate Lorem Ipsum which looks reasonable.
The generated Lorem Ipsum is therefore always free from repetition, injected humour, or non-characteristic words etc.

<script type="text/javascript">
resizeIframe();
function resizeIframe() {
var me = window.name;

if (me){
var iframes = parent.document.getElementsByName(me);
if (iframes && iframes.length == 1) {
var height = document.body.scrollHeight;
iframes[0].style.height = height + "px";
}
}
}
</script>
</apex:page>

 

Message Edited by TehNrd on 03-03-2009 03:36 PM
TehNrdTehNrd

Can anyone from salesforce.com provide insight on this? Based on the comments above this should not work unless the way VF pages are served has changed. It would be great to have confirmation or additional details as I don't want to implement functionality that may break in the future.

Thanks,
Jason

Message Edited by TehNrd on 03-04-2009 09:29 AM
JAW99JAW99
Dynamic resize does not work for me currently.
bc2000bc2000

TehNrd,

 

This page does not resize dynamically, does it still work for you?  Maybe something changed since you last posted?

 

I have tried adjusting the height, placing it in different sections, no resizing occurs.

 

I'd love to know how you got it working!

 

BC 

sfdcfoxsfdcfox

Currently, this does not occur, because of cross-domain scripting behavior. This is an intentional sabotage so that the page does not have access to any cookies or outer HTML DOM objects, which is a potential security hole. At some point, I thought they'd have a fix for this in Winter '10, but I can't seem to find it.

 

But you're not alone:

 

http://ideas.salesforce.com/article/show/10079440/Dynamically_Resize_iFrame

http://ideas.salesforce.com/article/show/10095804/Host_visualforce_on_the_same_domain_as_the_org

 

... etc ...

bc2000bc2000

sfdcfox,

 

Thank you for updating us on this issue, I appreciate the info.

 

Well hopefully they'll spend more time coming up with a way to do this natively than putting in a fix!

 

Thank you,

BC 

TehNrdTehNrd
Our org is weird. The VF pages are not served from a different domain. I have no idea why this is.
Message Edited by TehNrd on 10-14-2009 01:29 PM
Tim__cTim__c

I had this crazy idea to write the height value to a custom config from the visualforce page. And then add a s-control to the page layout that reads the height value from the custom config and sets the iframe height.

 

This would let you communicate the height value across domains BUT s-controls are being deprecated. The other issue with my idea is timing. Can the visulaforce page set the value to the custom config object before the iframe needs it?

 

Anyone have input on using this approach? Is there any other way to inject javascript into a page layout without using an s-control? Can the ajax toolkit do anything to help?

 

I have a funny feeling that by the time a workaround is found Salesforce is going to add dynamic height to inline visualforce pages.

dmitri_inetindustrydmitri_inetindustry

We just released an AppExchange package that will change height of custom inline visualforce page components. It consists of several components where most of the configuration logic is happening via javascript from sidebar homepage component. HTML5 was key to make this happen via postMessage() protocol that allows for controlled XSS. Current version doesn't support IE6 or IE7.

 

Check it out on AppExchange, feel free to use in your projects and expand on the functionality.

 

https://sites.secure.force.com/appexchange/listingDetail?listingId=a0N30000004cEEyEAM#

 

Thanks,

Dmitri

Salesforce Consulting and Force.com Sites Design & Development

Abhishek Shukla 4Abhishek Shukla 4

Hi dmitri_inetindustry,

  Above mentioned plugin wors finme except for the scenario for PAGEBLOCKSECTION collapse action.
Please help if there is any way to achieve this.