You need to sign in to do that
Don't have an account?
JasonG
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?
JasonG
Refused to display 'url" in a frame because it set 'X-Frame-Options' to 'sameorigin'.
Karthik K
May be give it a shot with lightning:container
JasonG
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.