473,385 Members | 1,780 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Problem When Using execCommand("SaveAs",false,".txt")

Hi All!

I am using Javascript to export some content in a popup (in this case, just 5 simple words) to a text file. This works fine and the user can save the text file.

Upon opening the file, it appears to be just a basic text file, however, i encounterd a problem importing this into flash (thats another story!). The text file needs to consist of just a line of text for the import (ie. word1=hello&word2=world), this is how it appears in notepad. But, when opened in a hex editor, it shows that there are stops inbetween every letter/number! (w.o.r.d.1.=.h.e.l.l.o.&.w.o.r.d.2.=.w.o.r.l.d) These are represented as 00 in hex...

I think this may be a problem with my javascript as i am fairly new to the language.

Any help would be greatly appreciated!

Cheers.

Gav
Sep 25 '07 #1
4 4185
acoder
16,027 Expert Mod 8TB
Post the code you have used.
Sep 25 '07 #2
Heres the Javascript code im using

Expand|Select|Wrap|Line Numbers
  1. <script language=JavaScript>
  2.  
  3. function test() {
  4. output = window.open("", "output", "width=600, height=600, toolbar=no, titlebar=no, location=no, directories=no, status=no, menubar=yes, scrollbars=no, resizable=no, copyhistory=no,"); 
  5.  
  6. output.document.write("word0="+word1_txt.value+"&"+"word1="+word2_txt.value+"&"+"word2="+word3_txt.value+"&"+"word3="+word4_txt.value+"&"+"word4="+word5_txt.value);
  7.  
  8. output.document.execCommand("SaveAs",false,"*.txt")
  9.  
  10. output.close();
  11.  
  12. }
  13.  
  14. </script>
The word1_txt.value are needed for the users input on the main page.

I have recently discovered that i can save as a .doc file and the problem goes, this is ok for a temporary solution however, if it is possible i would rather use .txt.

Cheers
Sep 25 '07 #3
acoder
16,027 Expert Mod 8TB
See this link. Read the section on null bytes.
Sep 25 '07 #4
Great! This looks like the kind of thing im after! Ill have a go at integrating this with what i've done at the moment.

Thanks for the help!

Gav
Sep 25 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: lir | last post by:
Hi, I am trying to save a fram in a page using the execCommand("saveas") the html is save currectly but I can not save the gif on that page. How can I save the fram with the gif via...
5
by: comshiva | last post by:
Hi all, I have converted my existing ASP.NET project from 1.1 to 2.0 and i have found that everything works fine except the linkbutton control in my datagrid which throws an javascript error when...
8
by: Ian Davies | last post by:
Hello I have the following sql string to run as a command in my VB6 project to update mysql table strSQL = "LOAD DATA INFILE " & ImportFile & " INTO TABLE tPupils FIELDS TERMINATED BY ','...
2
by: psanjay | last post by:
Hi, Am unable to open javascript SaveAs dialog box in Firefox browser. Following is the script, <a href="javascript:void(0);" onclick="document.execCommand('SaveAs',false,'*.xyz');">Save this...
3
Coldfire
by: Coldfire | last post by:
Hello, The issue is: I have a webpage that displays image in img tag while taking its src from a remote url ( dynamically). Now, my client want this functionality to ask for "Save at any location"...
6
by: mrobinson86 | last post by:
Hey guys, wondered if anybody could help me out with a pretty simple piece of code that has been driving me crazy for the past few days? I am trying to create a client side self sustaining message...
6
by: =?Utf-8?B?U2NvdHQgVHJpY2s=?= | last post by:
I followed the instructions from MSDN for Webclient UploadFile and I get an error: Could not find file 'C:\testfile.xls'. If I add the file (c:\testfile.xls) to the server I do not get the error...
4
by: James Lucero | last post by:
Below is my code. The error is "Compile Error Variable not defined". wdOrientLandscape is highlighted. Again this the portion of the code from a VB module created in Excel. The previous lines of code...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.