+ Start a Discussion
Aruna VasahanAruna Vasahan 

Iframe inside lightning component

Hi guys,
           I have a visualforce page which I am embedding inside a lightning component using iframe. The code is 
<aura:component implements="force:lightningQuickAction,force:hasRecordId" access="global">
    <iframe src="{! '/apex/vf_page?Id=' + v.recordId }" width="100%" height="1000px;" frameBorder="0"/>
</aura:component>
I need the iframe to fit all the contents of the visualforce page without setting width and height to iframe. Do anyone have solution for this?  
NagendraNagendra (Salesforce Developers) 
Hi Aruna,

Please give a try with sample code below which should do the trick.

Add this to your <head> section:
<script>
  function resizeIframe(obj) {
    obj.style.height = obj.contentWindow.document.body.scrollHeight + 'px';
  }
</script>
And change your iframe to this:
<iframe src="..." frameborder="0" scrolling="no" onload="resizeIframe(this)" />
For more information please check with below links. Hope this helps.

Regards,
Nagendra.

 
Aruna VasahanAruna Vasahan
Nagendra,
             Only after going through the above solution I came here to post the question. The above coding can be used only for javascript pages and there too it doesn't worked for me. The above code is moving only the vertical scrollbars so it doesn't works.
Thanks
Aruna 
sfdcBahusfdcBahu
Hi Aruna, were you able to find the solution for this? please advise