title: Real-time Html Edtior with iFrame (what I am doing wrong)
body: <p>I have been trying to create real time html editer using iframe and textarea but for some reason my code does not work as expacted.</p>
  
  <p>could someone tell me what is wrong with my code?</p>
  
  <pre><code> &lt;script type="text/javascript"&gt;
   var old = '';
  
   function update(){
    var textarea = document.getElementById('code');
    var iFrame = document.getElementById('output').contentWindow.document;
  
    if (old != textarea.value){
      old = textarea.value;
      iFrame.clear();
      iFrame.write(old);
    }
  
    window.setTimeout(update, 150);
   }
  </code></pre>
  
  <p>html</p>
  
  <pre><code>  &lt;body onload="update()"&gt;
  
    &lt;textarea id="code"&gt;&lt;/textarea&gt;
  
    &lt;iframe id="output"&gt;&lt;/iframe&gt;
    &lt;/body&gt;
  </code></pre>