You need to sign in to do that
Don't have an account?
Salesforce Practice 46
iframe allowfullscreen not working for innerHTML
I need your help. When I am using unescapedHtml, I am able to see option to fullscreen the video played in iframe. On the other hand, when I am using innerHTML, it is not working. I need to use innerHTML to get its element. So, please help.
Component code -
<aura:component >
<aura:handler name="render" value="{!this}" action="{!c.onRender}"/>
<aura:attribute name="myhtml" type="string" />
<div id="articleContainer" aura:id="container"/>
<aura:unescapedHtml value="{!v.myhtml}"/>
</aura:component>
Controller code -
({
onRender: function(component, event, helper) {
var myhtml = '<iframe allowfullscreen width="560" height="315" src="https://www.youtube.com/embed/hBrSHW-vLgw" title="Rockstar Buddies Channel" frameborder="0"></iframe>';
var el = document.createElement( 'html' );
el.innerHTML = myhtml;
var divContainer = component.find('container');
if (divContainer){
divContainer.getElement().innerHTML = el.innerHTML;
}
component.set("v.myhtml", myhtml);
},
})
Component code -
<aura:component >
<aura:handler name="render" value="{!this}" action="{!c.onRender}"/>
<aura:attribute name="myhtml" type="string" />
<div id="articleContainer" aura:id="container"/>
<aura:unescapedHtml value="{!v.myhtml}"/>
</aura:component>
Controller code -
({
onRender: function(component, event, helper) {
var myhtml = '<iframe allowfullscreen width="560" height="315" src="https://www.youtube.com/embed/hBrSHW-vLgw" title="Rockstar Buddies Channel" frameborder="0"></iframe>';
var el = document.createElement( 'html' );
el.innerHTML = myhtml;
var divContainer = component.find('container');
if (divContainer){
divContainer.getElement().innerHTML = el.innerHTML;
}
component.set("v.myhtml", myhtml);
},
})
My question is, full screen option is appearning using the second code but not using first code. However, for my requirement, I need to use first way only because it also helps me using get element by id and other methods. If my html is big and contains h3 tag, I am not able to get html element through javascript if I am using second approach. So, I need solution which helps into this as well.
By removing the first code does not fix it, we want same functionality using first code "innerHTML".
Note: We are also able to show fullscreen using "lightning:formattedRichText" but that has same issue of get element by id not fetching component.