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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SaveAs Function question... 1

Status
Not open for further replies.

codeone

Programmer
Joined
Mar 25, 2003
Messages
343
Location
US
Hello,
I have a saveas function in my page and when it saves as either a text or html it adds this:

line one [] []

now they dont look like two brackets facing eachother they look like two black squares, I just made those as an example.

I think it is because the files are being saved as unicode, and I tryed all the other language options and they don't save the string they save the entire html document...

heres my code:

Code:
 <script>
  function save()
{
        str = document.forms[0].content.value;
	mydoc = document.open();
	mydoc.write(str);
	mydoc.execCommand(&quot;saveAs&quot;, false, &quot; &quot;);
	mydoc.close();

  }
</script>

Now is there anyway I can make this work without it adding the two black squares at the end of each line?

Perhaps a xml way or vbscript way or better javascript way...

thanks, and all help is most appreciated..

code one


p.s. this is a client side project.
 
It's quite possible that those box characters are Carriage Return or Line Feed characters. Not sure about how to remove them, however.

Dan
 
Hi codeone,

Can you use ActiveX in your environment?

Code:
<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;>
<html><head><title>TEST</title>
<script language=&quot;JavaScript&quot;>
function strtxt(txt){
 var strObj = new ActiveXObject('Scripting.FileSystemObject');
 var strFile = strObj.OpenTextFile('test.txt', 2, true);
  if(!txt) {
   txt = prompt('What would you like to see stored?','Data Please..'); }
   strFile.WriteLine(txt);
   strFile.Close();
}
</script></head><body>
<textarea name=&quot;content&quot; rows=&quot;5&quot; cols=&quot;20&quot; onBlur=&quot;strtxt(this.value)&quot;>
</textarea>
</body></html>
 
Hey Lrnmore,

Thanks for the script man, I appreciate that...

but, how do I call it to save the text?

Never used activex before..

thanks,

code one
 
oh nevermind, I see whats happening it does it onblur and saves it to desktop...

thanks alot!

code one
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top