How can we read or write a file(e.g. xxx.txt) using javascript?
read and write a file using javascript
Collapse
X
-
Tags: None
-
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..
nehaComment
Comment