JSFiddle - React, Tailwind, and code Playground
by Jeremy Banks
JavaScript
var sandboxed = function(source) {
var onebox = $("<iframe sandbox='allow-same-origin'></iframe>");
onebox.appendTo("body");
setTimeout(function(){
var doc = onebox.prop("contentWindow").document;
console.log(doc);
doc.body.innerHTML = source;
// doc.open();
// doc.write("<!doctype html><html><body>" + source);
// doc.close();
onebox.css({
display: "block",
width: "100%",
border: "0",
borderBottom: "1px solid black"
});
// This is fine, it's just that the document
// is changed when the frame is moved elsewhere
// in the DOM.
}, 0);
}
sandboxed("<b>hello world</b>");