How to get innerHtml in iframe by angular

    <iframe  -sharporbitIframe  [src]="chargeHtml|safe" width="100%" height="100%" frameborder="0" align="center"></iframe>
window.document.body.innerHTML = document.getElementById("orbitIframe").contentWindow.document.getElementsByTagName("body").innerHTML

this prompts contentWindow" does not exist on type "HTMLElement"

Apr.27,2022

const iframe = document.getElementById ('orbitIframe');
const iframeWin = (< HTMLIFrameElement > iframe) .contentWindow;

you can add a < HTMLIFrameElement >, but you probably won't get the data.


should be cross-domain?


then use contentDocument

.
Menu