Okarin
Okarin

Reputation: 974

Creating a popup and writing it as txt in Javascript

So, I have a rather odd question. I am writing client-side code (it HAS to be client side as a basic requirement) and need to create a popup which will display some code-generated output. Ideally, people should be able to copypaste this output in a txt file.

Now, when I create the window I can only write in it with my_window.document.write("Blah blah blah"). This means that I have to use html tags for things like going to the next line, and I basically have no easy way to tabulate. Since this is meant to be a data file, this is kind of annoying. Seeing how a browser is perfectly able to open a .txt file, isn't there a way to write to this document telling the browser to read it not as an .html, but as a .txt file? Thanks.

Upvotes: 0

Views: 168

Answers (1)

bfavaretto
bfavaretto

Reputation: 71918

I don't think that's possible. What tells the browser the type of document is the content-type HTTP header, which is sent from the server.

But you can always dump your whole content into a <pre> element, or a <textarea>.

Upvotes: 2

Related Questions