Edit in JSFiddle

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 = url;
}
<div>
    <p>HTML &lt;body&gt; 태그 안에 들어갈 내용을 입력하세요.</p>
    <p><textarea id="code" style="width:99%;height:100px">&lt;p>안녕하세요.&lt;/p></textarea></p>
</div>
<button onclick="createHTMLDocument()" style="line-height:3em">HTML 문서로 만들기</button><br>
<a href="#" id="link" target="_blank"></a>