title: How to read and write from/into text file using javascript?
body: <p>Do any one have a sample code of how to read and write from/into text file using javascript</p>
  
  <p>What i tried is like created a iframe and load text file into it from iframe i read the content and using string operation make some changes, and i have no idea how to write back to text file.
  and also on ie browser this code is not working.</p>
  
  <p>My text.txt file contain
  First line
  second Line
  Third Line
  Fourth Line</p>
  
  <pre><code>&lt;html&gt;
  
  &lt;head&gt;
    &lt;title&gt;&lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;script language="JavaScript" type="text/javascript"&gt;
  &lt;!--
  
  
  var srcFrame;
  
  function loadOuter(doc) {
   srcFrame = document.getElementById("hiddenContent");
   srcFrame.src = doc;
  
  
  
   transferHTML();
  
  }
  
  function transferHTML(){
   srcContent='';
   if (srcFrame.contentDocument){
   alert("document");
    srcContent=srcFrame.contentDocument.getElementsByTagName("BODY")[0].innerHTML;
   }
   else if (srcFrame.contentWindow){
    alert("window");
    srcContent=srcFrame.contentWindow.document.body.innerHTML;
   }
  
  srcContent.length;
  alert(" before push "+srcContent);
  var arrayText="Last Line";
  var lines = srcContent.split('\n');
  lines=lines.slice(0, -1);
  lines.push(arrayText,"&lt;/pre&gt;");
  lines = lines.join('\n');
  srcContent=lines;
  alert(srcContent);
  document.getElementById("outerDisplay").innerHTML = srcContent;
  }
  
  &lt;/script&gt;
  
  &lt;INPUT TYPE="button" VALUE="Test.txt" onClick="loadOuter('Test.txt')" &gt;
  
  &lt;div id="outerDisplay"&gt;&lt;/div&gt;
  
  &lt;iframe  id="hiddenContent" width="200" height="200" style="position:absolute;visibility:hidden;" &gt;&lt;/iframe&gt;
  
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>