Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
405 views
in Technique[技术] by (71.8m points)

c# - How to create and save a text file with JavaScript

Do you know any cross-browser method to create and save a file with JavaScript on the client-side?

Considerations:

  1. I can't save it on the server because the file is going to be read from a fiscal printer.
  2. The server can't access the client. This is obvious because we are talking about a web application in the web, so the server can't access a client folder.
  3. New ActiveXObject("Scripting.FileSystemObject"); is ONLY for Internet Explorer and even then not for all versions.
  4. We are talking about printing on a fiscal printer, so I can't ask the cashier in the supermarket to download the text file and save it in a folder where the fiscal printer can read it.
  5. If not JavaScript, what else can I use in my ASP, .Net 4.0, C# web application?
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Basically, you said it, "we are talking about a web application." Do you know any web applications that save a file to your hard drive (besides cookies) without showing you a download prompt first?

Having said that, browsers have started to offer a persistence API that goes beyond cookies. (See, for example, this article.) But such a solution wouldn't meet your requirement of being cross-browser.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...