I am facing an issue with styling in an iframe when trying to append my own angular component. Despite various attempts, I have been unsuccessful in getting the styling to apply to the component within the iframe.
Upon loading the iframe, I use JavaScript to add the component as follows:
let component= document.getElementById('componentId');
let divInIframe= iframeWindow.document.getElementById('divInIframeId');
divInIframe.appendChild(component);
Even after trying to manually add the component's styling to the iframe's CSS file and applying styles through JavaScript post iframe load, the component still lacks the desired styling.
let cssLink = document.createElement("link");
cssLink.href = "../../assets/component.css";
cssLink.rel = "stylesheet";
cssLink.type = "text/css";
iframDoc.head.appendChild(cssLink);
Despite experimenting with ViewEncapsulation.None and other solutions, nothing seems to make it work. The only solution that has worked is using encapsulation:ViewEncapsulation.ShadowDom, but unfortunately this is not compatible with IE11.
If anyone has a suggestion on how to resolve this issue, I would greatly appreciate it.