JSFiddle - React, Tailwind, and code Playground
HTML
Select a file : <input id="fileInput" type="file"><br><br>
Html Codes : <textarea id="displayHtml"></textarea><br><br>
<div id="displayPage">Display the Html Page here</div>
JavaScript
function handleFileSelect(evt) {
var file = evt.target.files[0]; // File inputs are an array - get the first element
var reader = new FileReader();
reader.onload = function(e) {
// Render the supplied file
document.getElementById('displayHtml').value = e.target.result
document.getElementById('displayPage').innerHTML = e.target.result;
};
// Read in the HTML file.
reader.readAsText(file);
};
document.getElementById('fileInput').addEventListener('change', handleFileSelect, false);