Reputation: 113
I have been working on an on/offline text-editing HTML page to take notes. It has a <textarea/>
like the ask page.
The problem is if the browser crashes, then some work may be irrecoverable. What is a simple, clean way to save the real-time contents of the HTML page to a .html file? In Chrome or IE is there any way to save the HTML document as it is exactly displayed?
I tried a File...Save As
in Chrome and IE will not persist the text changes I made.
The question https://stackoverflow.com/questions/21486908/save-a-webpage-after-its-variables-have-been-changed looks similar, but is lengthy, and nobody answered it (yet).
Upvotes: 1
Views: 672
Reputation: 515
The HTML/JS context in a browser runs in sandboxed mode, meaning that you can't read or write files programatically in JS directly to your filesystem. Take a look at web storage to check a way to do it indirectly (using browser abstractions). It's one of the most common ways of implementing persistence in an offline web application.
You'll probably find browser-specific functions that can make this, but I don't know of any portable solution for this that doesn't rely on plugins.
There's a similar question, but I think you'll run in the same problem that you can't save the changes in the HTML structure and content
Upvotes: 1