Reputation: 3604
Is it possible to save out some javascript object purely on client-side?
My question come from the following workflow: a user enters and posts a text, i do some processing on the server side and return processed text to the user. The user can do some modifications to the returned text, if he doesn't like some processed parts of it. Is there any client-side javascript functionality so the user pressed the button 'save' and it pops a save file dialog as if the user downloaded this file from a server? Or I need a server interaction for example to post the results and return them to the users as a file?
Upvotes: 2
Views: 605
Reputation: 6206
You could implement this functionality with a server side functionality, but not with JavaScript. Pressing 'Save' would create an AJAX call to the server which responds with the file correct headers, making the browser respond with a "Save file" dialog.
Upvotes: 1
Reputation: 519
with javascrpipt you don't have access to the filesystem on the clients pc (except of the cookies). so you have to send him a downloadable file.
Upvotes: 1
Reputation: 178411
No. Unassisted JavaScript cannot save files (IE with activeX/WHS can use the file system, mozilla products may have something here which I have not investigated)
But you can popup a window or write it to an iframe which can be printed to for example PDF which is saved on the client
Upvotes: 1