To write some content into some file or read content from file and wants to store all file content in one variable and wants to dispaly this as a alert or some thing the following program will be helpful.This works in Internet Explorer.
Code:
<HTML>
<HEAD>
<SCRIPT language="JavaScript">
function WriteAndReadFile()
{
var fso = new ActiveXObject("Scripting.FileSystemObject");
var fh = fso.CreateTextFile("D:\\Test.txt", true);
fh.WriteLine("Text Example 1");
fh.WriteLine("Text Example 2");
fh.WriteLine("Text Example 3");
var f;
var str;
f = fso.OpenTextFile("D:\\Test.txt", 1);
var s=f.ReadLine();
s=s+"\n"+f.ReadLine();
s=s+"\n"+f.ReadLine();
alert(s);
f.Close();
}
</SCRIPT>
</HEAD>
<BODY>
<P>
<SCRIPT language="JavaScript"> WriteAndReadFile(); </SCRIPT>
</P>
</BODY>
</HTML>
Showing posts with label javascript read and write file code download. Show all posts
posted by
Pavan
filed under
javascript read and write file code download,
read file javascript,
write file javascript