1

Im trying to manipulate my iframe from the renderer but i can't get to the Document of the Iframe.

Component:

<aura:component access="global" implements="flexipage:availableForRecordHome,force:hasRecordId">
    <iframe aura:id="FileFrame" src="about:blank" style="width:100%;height:500px"></iframe>
</aura:component>

Renderer:

({
    afterRender: function(component, helper) {
        var action = component.get("c.getMyVFpageA");
        action.setCallback(this, function(response){
            console.log('hiaudsilhudas');
            var doc = component.find("FileFrame").getElement().contentDocument;
            console.log(doc);
            doc.open();
            doc.write('<html><head><title></title></head><body>Hello world.</body></html>');
            doc.close();
            });
        $A.enqueueAction(action);}
})
5
  • 1
    any errors in the browser's console or network tab? please update your post if any.
    – glls
    Commented May 23, 2017 at 16:27
  • did you try contentWindow.document (not sure here as I got it from a SO answer) after getElement or add a regular Id to the iframe and use: document.getElementById('iFrameId').contentDocument;
    – Eric
    Commented May 23, 2017 at 17:10
  • 2
    The Locker Service documentation lists contentDocument as Not To Be Supported for iframes.
    – Keith C
    Commented May 23, 2017 at 18:33
  • 3
    See salesforce.stackexchange.com/q/122250 for a method for generating HTML dynamically in Lightning. You can't use an iframe.
    – sfdcfox
    Commented May 23, 2017 at 18:45
  • Thanks everyone, ive done some more testing and i think there with lockerservice and clickjackprotection for VF Pages there is no way to achive this.
    – Nils Rosen
    Commented Jun 12, 2017 at 14:58

0

You must log in to answer this question.

Browse other questions tagged .