473,624 Members | 2,496 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Allow download of a "virtual" file

Hello !

I am having a problem which I thought was an easy one but which starts
to drive me crazy.

Imagine that I have a text displayed in a div. I would like a button
to download a text file containing this text (no formatting, just
text).

How should I do that ?
Can I somehow build a file in javascript and then propose to the user
to save it ? (the normal "save or open with" dialog)

Or am I forced to have a temporary file on the server to link to ? and
then wouldn't the browser simply display this txt file instead of
proposing to save it ?

Any help would be welcomed !
Thanks in advance

Barth
Nov 21 '07 #1
2 2113
On Wed, 21 Nov 2007 09:33:22 -0800 (PST), ba************* ******@gmail.co m
wrote:
[downloading text using JavaScript]
Or am I forced to have a temporary file on the server to link to ?

I would imagine so.

and then wouldn't the browser simply display this txt file instead of
proposing to save it ?

If you send it with an HTTP header such as the following:

Content-disposition: attachment; filename=someth ing.txt

....then most browsers will bring up a requester to save the file, with the
specified name as a default.
--
Safalra (Stephen Morley)

Sortable Tables In javascript:
http://www.safalra.com/web-design/ja...rtable-tables/
Nov 21 '07 #2
Thank you for your help !

Barth
Nov 22 '07 #3

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

Similar topics

12
13449
by: cppaddict | last post by:
Hi, I know that it is illegal in C++ to have a static pure virtual method, but it seems something like this would be useful when the following 2 conditions hold: 1. You know that every one of your Derived classes will need to implement some method, but implement it differently, and that the base class cannot implement it. This is where pure virtual comes in.
3
1347
by: dfcoates | last post by:
Here's the situation: I have several 3rd party applications that write trace files and log files. We are now being mandated to "scrub" the trace files and log files in realtime. "scrub" = remove sensitive data from trace/log. We only have the ability to specify the log file location in each of these various 3rd party applications. Is it possible to create some sort of "virtual file" that the 3rd party
175
8768
by: Ken Brady | last post by:
I'm on a team building some class libraries to be used by many other projects. Some members of our team insist that "All public methods should be virtual" just in case "anything needs to be changed". This is very much against my instincts. Can anyone offer some solid design guidelines for me? Thanks in advance....
4
1380
by: Mark Rendle | last post by:
Hi I'm writing a page which outputs CSV data for download. It's all working fine, setting ContentType to "text/csv", except when the "Open/Save" dialog appears, the filename shown is "ExportRun.aspx". Is there any way I can change this to, e.g., "mydata.csv" without having to generate a temporary file on the server? Thanks Mark
0
8240
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8175
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8625
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8336
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8482
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5565
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4177
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2610
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1487
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.