0

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);}
})
  • 1
    any errors in the browser's console or network tab? please update your post if any. – glls May 23 '17 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 May 23 '17 at 17:10
  • 2
    The Locker Service documentation lists contentDocument as Not To Be Supported for iframes. – Keith C May 23 '17 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 May 23 '17 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 Jun 12 '17 at 14:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.