Somewhat new to Salesforce. I have a lightning component that has an iframe in it. The component will be in the lightning communities. There is a method in the controller that gets called once the iframe is loaded. For some reason I can't access any DOM elements, it's always null. Here's an example snippet:
Component
<aura:component implements="forceCommunity:availableForAllPageTypes">
<iframe src="/mypage" onload="{!c.iframeOnLoad}" class="myIframe" frameBorder="0"/>
</aura:component>
Controller
({
iframeOnLoad: function(){
try{
customCss = document.getElementById('customCSS').innerHTML;
}
catch(ex){
console.log(ex);
}
}
})
The customCss element is actually there but for some reason it's not getting it. If I put that js snippet in the browser console, it does get the innerHTML in that element. I hope that understands it.