JSFiddle - React, Tailwind, and code Playground
by bjogden
JavaScript
var i = document.createElement('iframe');
i.src = "about:blank";
i.id = "testing";
document.body.appendChild(i);
// iframe been added to page
var j = document.getElementById('testing').contentDocument;
j.open();
var js = "<html><head>" +
"<scr" + "ipt>window.top.document.getElementById('testing').sandbox = 'allow-scripts';</scr" + "ipt>" +
"</head><body>" +
"<p>Hi</p>" +
"<scr"+"ipt>var p = document.createElement('p'); p.innerText = 'here'; console.log(p); window.top.document.body.appendChild(p);</scr"+"ipt>" +
"</body></html>";
j.write(js);
j.close()