3
I am working with the following code to import and display text files:
HTML
<input type='file' accept='text/plain' onchange='openFile(event)'>
<div id='output'>...</div>
Javascript:
var openFile = function (event) {
var input = event.target;
var reader = new FileReader();
reader.onload = function () {
var text = reader.result;
var node = document.getElementById('output');
node.innerText = text;
};
reader.readAsText(input.files[0]);
};
But I came up with the need that when importing, the content is interpreted as HTML, because the file contains lists in <ul><li>
.
Would that be possible? If so, can you explain to me what I should change?