title: How to read and display html file
body: <p>I'm making a html editor but the problem is that when someone needs to view an html file i don't know how to display the text from the file.</p>
  <pre><code>&lt;input type=&quot;file&quot; onchange=&quot;previewFile()&quot;&gt;&lt;br&gt;
  &lt;p id=&quot;txt1&quot; src=&quot;blank.html&quot;&gt;&lt;/p&gt;
  </code></pre>
  <pre><code>&lt;script&gt;
  function previewFile() {
    const preview = document.getElementById('txt1');
    const file = document.querySelector('input[type=file]').files[0];
    const reader = new FileReader();
  
    reader.addEventListener(&quot;load&quot;, function () {
      // reads image file to a blob string
      preview.src = window.URL.createObjectURL(file);
    }, false);
  
    if (file) {
      reader.readAsDataURL(file);
    }
  }
  &lt;/script&gt;
  </code></pre>
  <p>I used this script to read a file and display it by changing the paragraph src to a blob link, but looks like the paragraph dosn't get the text by a html text link using src.
  Is there a way to do it?</p>