Is it possible to save the contents inside of a Div as a file (Could be .txt or .html or anything) and loading the contents from the file later on (Replacing the content already in the DIV). If this can’t be done via JS/Jquery, would it be possible in a diff language (php?).
For example:
<div class="etc">
Content here
</div>
<a href='link.html' download>
<button>Save Content</button>
</a>
<button>Load Content</button>
2
Answers
You can use the
iframe
to display the contents from the file.. but the file should be hosted somewhere.. you can’t directly read local system files without user upload.And for downloading contents as a file refer here
I actually had some old Code laying around that did this.. So this is a very basic example that you can extend from.. It requires HTML5 tho.. It could be vastly improved upon too (old code, throws up)
Another route would be Posting contents using Jquery.ajax and creating the file on your backend (like php) that way you could generate more complicated file formats than raw text with a file extension