Do you know any cross-browser method to create and save a file with JavaScript on the client-side?
Considerations:
- I can't save it on the server because the file is going to be read from a fiscal printer.
- 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.
- New
ActiveXObject("Scripting.FileSystemObject");
is ONLY for Internet Explorer and even then not for all versions. - 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.
- If not JavaScript, what else can I use in my ASP, .Net 4.0, C# web application?
Do you know any cross-browser method to create and save a file with JavaScript on the client-side?
Considerations:
- I can't save it on the server because the file is going to be read from a fiscal printer.
- 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.
- New
ActiveXObject("Scripting.FileSystemObject");
is ONLY for Internet Explorer and even then not for all versions. - 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.
- If not JavaScript, what else can I use in my ASP, .Net 4.0, C# web application?
4 Answers
Reset to default 4Basically, 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.
Your only options are to use persistance APIs from HTML5 or to create a browser plugin (activex control on IE, NPAPI plugin on others) that can do the file access for you. You could use FireBreath to do this, and it would be relatively simple if you know C++.
That said, it is a really dangerous idea; it is difficult to prevent people from using your plugin in other pages, so your plugin has to somehow be smart enough to keep itself from being abused by malicious sites that want to read (or even write) arbitrary data to your hard drive.
There is, after all, a reason why browsers don't natively support this. I'd look at HTML5.
you can do that by Client side Web services just make a function in web service to create a text file in your hard drive then convert the web service in to the client side service when u do that .Net framework make a client side java script then u will be able to call the server side function using Java script in client side after that your file will not be posted in the server it will remain save in your hard drive ok
we came out with a simple windows service nodejs app to be installed in the local machine. When the web application need to create a file it just sends an API call to this app using localhost and that will write the file for it. Cheers.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745194116a4616007.html
评论列表(0条)