473,387 Members | 1,678 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,387 software developers and data experts.

Possible to generate text files in javascript?

I'd like to be able to generate a text file in a web browser, then
supply a link which will allow users to save that file to disk. I'm
not trying to read from the local machine or even write directly to
the local machine, I'm simply trying to provide a file which the local
browser and save as it would any other URL.

Just to give some idea of my motivation, I'm working with encrypted
data which is decrypted locally (so the server never has access to the
data). I'd like to be able to save the cleartext in some cases as a
text file.

Thanks
-Ryan
Dec 13 '07 #1
3 1369
kerinin said the following on 12/12/2007 7:37 PM:
I'd like to be able to generate a text file in a web browser, then
supply a link which will allow users to save that file to disk. I'm
not trying to read from the local machine or even write directly to
the local machine, I'm simply trying to provide a file which the local
browser and save as it would any other URL.

Just to give some idea of my motivation, I'm working with encrypted
data which is decrypted locally (so the server never has access to the
data). I'd like to be able to save the cleartext in some cases as a
text file.
User clicks a button.
Browser opens new window with text file.
User uses File>Save As to save the text file.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Dec 13 '07 #2
User clicks a button.
Browser opens new window with text file.
User uses File>Save As to save the text file.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ -http://jibbering.com/faq/index.html
Javascript Best Practices -http://www.JavascriptToolbox.com/bestpractices/
Wouldn't the new window have HTML formatting as well as the text?
Dec 13 '07 #3
On Dec 12, 6:40 pm, kerinin <keri...@gmail.comwrote:
User clicks a button.
Browser opens new window with text file.
User uses File>Save As to save the text file.
[snip]
>
Wouldn't the new window have HTML formatting as well as the text?
If the servers sends the file with a "Content-Type text/plain" header
then it will just show as text.

Peter
Dec 13 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

39
by: Mark Johnson | last post by:
It doesn't seem possible. But would the following also seem a violation of the general notions behind css? You have a DIV, say asociated with class, 'topdiv'. Inside of that you have an anchor...
5
by: Dario de Judicibus | last post by:
I am trying to generate an XML file to be shown in IE by javascript. My code looks like top.x = window.open('','MyXML') ; top.x.document.write('<?xml version="1.0" encoding="ISO-8859-1" ?>') ;...
0
by: Horia Tudosie | last post by:
Using Visual Studio 2003 This is to report a series of bugs regarding the FlagsAttribute and (independently) the usage of interfaces in Web applications. Let’s declare xColors type like: ...
2
by: Stephen Tang | last post by:
Hi, I'm relatively new at this language, so I've been trying to find parallels to problems I've run into in the past. This is the hypothetical problem: I want to write a CD inventory...
8
by: dbaplusplus | last post by:
I worked on web development using java script many many years, so I am now a newbie to javascript. I have a single html page, which is generated dynamically using some programming language. Web...
11
by: Timofmars | last post by:
I'm try to Unload DB2 data from a table into a record sequential file on NT. I can an unload on Mainframe, but it doesn't seem to be an option in NT. In NT, all I can do is export/import. I can...
9
by: Asterbing | last post by:
Hi all, Don't know where to ask my question because the way to go is included in the possible answer itself by nature... You'll understand better below : Well, I have an HTML page containing a...
3
by: Greg Guarino | last post by:
Let me first apologize for the myriad bits of ignorance that are to follow. Our company does consulting work. We have found over the years that it is best to have an agreement in writing, both...
23
by: Geoff Cox | last post by:
Hello, Is it possible to use php to generate different menus for users who have access to files in different folders? For example, user Fred might be able to access files in folders A, B and...
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: 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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.