JSFiddle - React, Tailwind, and code Playground
HTML
<div>
<p>HTML <body> 태그 안에 들어갈 내용을 입력하세요.</p>
<p><textarea id="code" style="width:99%;height:100px"><p>안녕하세요.</p></textarea></p>
</div>
<button onclick="createHTMLDocument()" style="line-height:3em">HTML 문서로 만들기</button>
<p><a href="#" id="link" download="my_document.html"></a></p>
JavaScript
function createHTMLDocument() {
var blob = new Blob(
['<!doctype html>','<html><head><title>Blob Example</title><body>',document.getElementById('code').value,'</body></html>'],
{type:'text/html'}
);
var url = URL.createObjectURL(blob);
var link = document.getElementById('link');
link.setAttribute('href', url);
link.innerHTML = '클릭하여 다운받기';
}