writing from a teaxtarea to a texfile, including the carriage return!!
I have implemented this code and it works very well, my only problem is that in my text area, I have
I have carriage returns in my text area that I need to preserve in my created text file
How do you make a variable with the value of the textarea without submiting or is this imposibel ?
Apr 7th, 2008 22:49
ha mo, Anthony T, Ronald Lammers, Thor Larholm, Peter Ned, Debbie Seidman, Jonas Sekamane,
Anyone got a solution to the previously stated problem ?
opening document as 'text/plain',
then write a string to the document,
then execcommand-saveas to a .txt file.
The save .txt file has 0x (ie.NULL) after EACH character in the string.
(i.e. A string of 'ABC' will be saved as A followed by NULL, followed
by B, followed by NULL, followed by C, followed by NULL)
You don't see the null when viewing through say notepad, but hex dump
of the file shows the NULLs.
How can we avoid having the nulls generated in a .txt file ?
(Note: If saved to a .doc file instead, there are no NULLs after each
Thanks in advance for comment!
This works fine, but not perfect. Trying to write a SAS-programfile
this way I found out execcomand-saveas insert null-values between all
characters (and some non-text-characters at the beginning of the file,
did not check the end). SAS chokes on those non-text-values.
Is there a way to get execcommand-saveas to save the iframe-content as
plain ascii (I tried setting mime tot text/plain but that didn't help)
I tried this in IE6.
To save a variable with document.execCommand('SaveAs'), you simply need
a hidden IFRAME (or any other such window object) and some scripting,
<iframe id="SaveFrame" style="display:none"></iframe>
Now you can call the SaveVarAsFile with your string as an argument. To
give an (optional) different filename for the SaveAs dialog box, simply
provide a string in the third argument of execCommand, e.g.:
If the SaveAs dialog box should simply give the user an option of
saving the variable as a .txt file, you can supply the string ".txt"
instead of the string "somefile.txt".