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
JasonGJasonG 

How do I get the host name inserted in an iframe src of a visualforce page being pulled into a lightning component?

How do I insert the host name into the url?
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,force:hasRecordId" access="global">
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    <aura:attribute name="host" type="String" />    
    <lightning:button label="Print" onclick="{!c.printModalToggle}" />   
    {! v.host + '/apex/VISUALFORCEPAGE?Id=' + v.recordId}                                      
<iframe src="{! v.host + '/apex/VISUALFORCEPAGE?Id=' + v.recordId}" width="100%" height="300px;" frameBorder="0"/>       
</aura:component>
And the controller 
({
	doInit: function(component, event, helper) {
		component.set('v.host', window.location.hostname);
	}
})
The {! v.host + '/apex/VISUALFORCEPAGE?Id=' + v.recordId} correct value but when it is entered into the iframe src attribute nothing happens. If I manually. enter that url into the address bar the page opens. Is there something with the <iframe src attribute that would give me trouble here?
JasonGJasonG
Refused to display 'url" in a frame because it set 'X-Frame-Options' to 'sameorigin'.
Karthik KKarthik K
May be give it a shot with lightning:container 
JasonGJasonG
I tried a lightning container as well it did not work. It has something to do with the X-frame-settings on the browsers. when i remove {!v.host} from the src attribute of the iframe tag and open it on edge it works still fails on chrome though.