read and write a file using javascript

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tkshankhari
    New Member
    • May 2007
    • 1

    read and write a file using javascript

    How can we read or write a file(e.g. xxx.txt) using javascript?
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Welcome to TSDN.

    See this link. Note that ActiveX only works with IE.

    Comment

    • nehacredo
      New Member
      • May 2007
      • 5

      #3
      u can read a word/txt File using this code..i hv copied my code here..check it out..
      <html>

      <head><title>sn ook.ca load document</title>

      <script language="JavaS cript">

      <!--//

      function loadworddoc(){

      var doc = new ActiveXObject(" Word.Applicatio n"); // creates the word object

      doc.Visible=fal se; // doesn't display Word window

      doc.Documents.O pen("C:\\Docume nts and Settings\\train er\\Desktop\\Sa mjad.doc"); // specify path to

      document


      //copy the content from my word document and throw it into my variable

      var txt;

      txt = doc.Documents(" C:\\Documents and Settings\\train er\\Desktop\\Sa mjad.doc").Cont ent;

      document.all.my area.value = txt;

      doc.quit(0); // quit word (very important or you'll quickly chew up memory!)

      }

      //-->

      </script>

      </head>

      <body>

      <p><input type=button onClick="loadwo rddoc();" value="Load">

      <p><textarea name=myarea cols=100 rows=25>nothing here yet</textarea>

      </body>

      </html>

      hope this may help u..
      neha

      Comment

      Working...