Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Writing text to a TXT file

Status
Not open for further replies.

javarookie

Programmer
Jul 19, 2002
2
CA
Hi, everyone. I need to write some text to a TXT file using javascript. I have the following script in y page

<script>
f=new File('c:\test.txt');
status=f.open('w');
f.write('test');
</script>

I get an error: 'File' undefined.

What am I doing wrong? I got this out of the book.
 
You can not write to a text file using Javascript on the client in that way, Javascript is NOT Java.
 
Because , JavaScript is used under IE
so , security is so important.

you can create file , by FileObjectSystem ( use <object .....)

it is a example :
<script language=&quot;JavaScript&quot;>
<!--
var fso = new ActiveXObject(&quot;Scripting.FileSystemObject&quot;);
var a = fso.CreateTextFile(&quot;c:\\testfile.txt&quot;, true);
a.WriteLine(&quot;This is a test.&quot;);
a.Close();
-->
</script>

but , it's not security for user , so , maybe ,some AntiVirus will Prompt for this action.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top