Reputation: 15027
I have this crazy idea to have a simple file .html
with textareas which can be edited but I don't want to have a database or any backend, just this one file and to be able to open it in browser and in browser add text and save it somehow....is this possible without backend and Database?
This a simple example:
<!DOCTYPE html>
<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Test</title>
</head>
<body>
<textarea rows="4" cols="50">
At w3schools.com you will learn how to make a website. We offer free tutorials in all web development technologies.
</textarea>
</body>
</html>
And what I want is to be able to save the changes made in Textarea to be permanent so when I copy that .htm file those changes should be there in source code of that htm file.
Upvotes: 2
Views: 1111
Reputation: 4691
It looks as if this is possible simply by using a browsers Save page as...
(or similarly named) feature, which can usually be easily accessed via CTRL+S.
Try this:
.html
file that has some element with the contenteditable
attribute.The changes you performed from within the browser should be there and should also be reflected in other editors or browsers.
However, as this is a browser feature that is not covered by any standard, some browsers might not offer this feature or save the file in its original, unchanged state. Also, the way browsers handle this can obviously be subject to change.
At the time of writing, this has been successfully tested with these browsers / OS:
Browsers / OS that do not save the changes:
Upvotes: 2
Reputation: 21262
It is possible to edit an HTML file on the fly using the contenteditable
attribute, or simply from your browser's web inspector.
For saving the page you could use localStorage
or other mechanisms to save it just on your computer.
It's even possible to create a simple text editor that works in your browser, just by going to this URL: data:text/html,<html contenteditable></html>
You can have a look at this blog post for more: https://www.simonewebdesign.it/how-to-make-browser-editor-with-html5-contenteditable/ (I am the author)
Upvotes: 2
Reputation: 181
In HTML5 you can use local storage to save the data.
The localStorage object stores the data with no expiration date. The data will not be deleted when the browser is closed, and will be available the next day, week, or year.
use the following example in javascript to store and retrieve the data:
// Store
localStorage.setItem("lastname", "Smith");
// Retrieve
document.getElementById("result").innerHTML = localStorage.getItem("lastname");
Upvotes: 0