简体   繁体   中英

File/Save HTML documents after adding new text content, and persisting changes in the .html file

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).

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM