Blob as HTML for iFrame

by Julien Etienne

HTML

<h1>
IFrame Below uses blob as content
</h1>
<iframe>

</iframe>

<p>
works in Chrome, Safari, Firefox. Used for <a href="http://webglfundamentals.org/webgl/lessons/webgl-animation.html" target="_blank">a Codepen like editor without needing a server</a>. PS: The link won't present editors in Edge because it can't work around this issue. It will display editors in Firefox/Chrome/Safari
</p>

JavaScript

var html = `
<script>
alert('YO')
</script>

<style>
body { 
  background: blue; 
  color: white;
}
</style>
<h1>This is Blob Content</h1>
`;

var blob = new Blob([html], {type: 'text/html'});
var iframe = document.querySelector("iframe");
iframe.src = URL.createObjectURL(blob);