JSFiddle - React, Tailwind, and code Playground
HTML
<div id="div"></div>
JavaScript
var iframe = document.createElement('iframe');
iframe.frameBorder = 1;
iframe.width = "500px";
iframe.height = "250px";
iframe.id = "iframe";
iframe.onload = function()
{
var doc = iframe.contentDocument || iframe.contentWindow.document;
var p = doc.createElement('p');
p.textContent = "Paragraph in iframe";
doc.body.appendChild(p);
};
document.getElementById("div").appendChild(iframe); //this is a div that I have in body.