Adding VisualForce page(already exposed in sites) in Site.com studio using an Iframe

In a site.com page I have an iframe and I want to access the vf page in this iframe. when I use the internel link of this vf page(https://cs2.salesforce.com/apex/page) as an iframe using site studio page (for testing purpose)and stay login to the org where this vf page is existing at that time it is working fine.

The exposed url(http://sample.force.com/calendar/apex/page) for that vf page is working in browser .

So now when I want to use this vf page as an iframe of a site.com studio page I am just using this exposed url in iframe but it is showing the blank iframe.

Not sure of how to implement this.

Thanks in advance

Answer

You need to make sure that the iframe src attribute uses the Force.com Site URL and not the instance URL and you need to make sure that the URL is https. If you use http the browser will likely not load the iframe. If you view your browser’s JavaScript console you’ll see something like

[blocked] The page at ‘https://sitestudio.na15.force.com/‘ was loaded
over HTTPS, but ran insecure content from ‘http://yoursite.com/test‘:
this content should also be loaded over HTTPS.

This will not work (doesn’t use Force.com site URL):

<iframe src="https://cs2.salesforce.com/apex/page" /> 

This will not work (not https):

<iframe src="http://yoursite.com/yoursite/page /> 

You can use the following. The browser will use the protocol of the current page which will be https in the studio and http when the page loads over http outside of the studio.

<iframe src="//yoursite.com/yoursite/page" />

Attribution
Source : Link , Question Author : Sagar Vadariya , Answer Author : Peter Knolle

Leave a Comment