Here is my code where I try to build real-time html editor.In javascript I get the text from textarea which has id=pure then in document.body.onkeyup function I pass the value to the textarea that has id=compiled. It does not work at all. I wonder if the problem is about open-writeln-close or another syntax?
function compile() {
var h = document.getElementById("pure");
var compiled = document.getElementById("compiled").contentWindow.document;
document.body.onkeyup = function(){
compiled.open();
compiled.writeln(h.value);
compiled.close();
};
}
compile();
<div class="form-group">
<label for="html">Write your HTML here:</label>
<textarea class="form-control" rows="3" id="pure"></textarea><br>
<textarea class="form-control" rows="2" id="compiled"></textarea>
</div>
<iframe>as compiled output.<textarea>doesnt have acontentWindow