Dynamic HTML Editor using HTML and Javascript

  1. In this article we will see how to create a Dynamic HTML Editor.
  2. This editor is created using HTML and Javascript.
  3. I have created frames to separate the region for typing and to show the result.
  4. We have used setTimeOut method to call a javascript method which picks whatever you write on left frame and updates on the right frame. The interval set to update the right frame is 150 milliseconds.

Code :

<script type="text/javascript">
    var structure = '<html>' +
'<head><title>Editor</title>' +
'<style type="text/css">' +
'.expand { width: 100%; height: 100%; background-color:black; color:white; font-family:comic sans ms; font-weight:bold; }' +
'.close { border: none;margin: 0px; padding: 0px; }' +
'.color{background-color:black; color:white;}' +
'html,body { overflow: hidden;}' +
'</style>' +
'</head>' +
'<body class="expand close">' +
'<form name="f" class="expand close">' +
'<textarea id="txtarea" wrap="hard" name="ta" class="expand close">' +
'</textarea>' +
'</form>' +
'</body>' +
    var headerText = '<html>' +
'<head><title>Header</title>' +
'<style type="text/css">' +
'#p1{font-family:comic sans ms; font-weight:bolder; font-size:30px; text-align:center; color:green}' +
'#p2{font-family:comic san ms; font-weight:bold; font-size:15px; text-align:center;color:green}' +
'</style>' +
'</head>' +
'<body bgcolor="silver">' +
'<p id="p1"><u>Dynamic Editor</u></p>' +
'<p id="p2">Edit And See</p>' +
'</body>' +

    var footerText = '<html>' +
'<body bgcolor="silver">' +
'</body>' +
    function init() {
    var old = "";
    function update() {
        var textarea = window.frame2.document.f.ta;
        var d = frame3.document;
        if (old != textarea.value) {
            old = textarea.value;
        window.setTimeout(update, 150);
<frameset rows="20%,*,20%" onload="init()">
<frame name="frame1" src="">
<frameset cols="50%,50%">
<frame name="frame2" src="">
<frame name="frame3" src="">
<frame name="frame4" src="">

The above code created a Dynamic HTML Editor. This editor gives you the dynamic feeling. The HTML code you write on left, immediately is updated on right frame. We can even write or use Javascript on this editor. This editor does not support jQuery.


  1. Nice blog Very useful information is providing by ur blog. Great beginning html tutorials Very clear and helpful for beginners.