Re: Can I save a text file?




Thomas Magma wrote:
I have a simple JavaScript application that will generate some text type
data for the end user. Is it possible to have a button that will allow them
to save this information to a text file?


<!-- VBSCRIPT CODING: WORKS ONLY ON MSIE (??)-->
<!-- IT ALSO TRIGGERS AN ALERT TO AUTHORIZE ACTIVE X TO RUN -->
<script type='text/vbscript'>
'html code: <button onClick="cFi( )">Save to C Drive </button>
'set variables:
Dim objFSO, objTextFile
Dim thecode
'start function triggered onClick of button:
Function cFi( )
Const ForReading = 1, ForWriting = 2, ForAppending = 8

Set objFSO = CreateObject("Scripting.FileSystemObject")

'text file is local drive and file to create that holds the data:
Set objTextFile = objFSO.CreateTextFile("c:\html-code.txt", True)

'thecode variable contains the data n your form you want to save to the
file:
thecode = newWin.document.myform.ta.value
objTextFile.WriteLine(thecode)
objTextFile.Close
End Function
</script>

.


Quantcast