JSFiddle - React, Tailwind, and code Playground

by scurrilus

HTML

<iframe src="https://www.morgenpost.de">

</iframe>

<div id="target">

</div>

TypeScript

setTimeout(() => {
  const iframe = document.querySelector('iframe');
  const target = document.getElementById('target');

  // Nur wenn es dieselbe Domain ist
  if (iframe && iframe.contentDocument) {
    const iframeContent = iframe.contentDocument.body.innerHTML;
    target.innerHTML = iframeContent;
  } else {
    console.error('Cross-Origin Problem: iframe content kann nicht ausgelesen werden.');
  }
}, 5000);