I have an HTML file with this code:
<html>
<head>
<script>
function saveTextArea() {
var newText = document.getElementById("textArea");
<!-- rewrite this file with <textarea id = 'textArea'> newText </textarea> -->
}
</script>
</head>
<body>
<button id = 'saveBtn'>Save</button>
<br>
<textarea id='textArea1'>MyText</textarea>
</body>
</html>
My use case is: In the browser, I rewrite what is in textarea. After, I press on the save button. In that moment I want to rewrite my HTML file with the new text in textarea, such that when reopening HTML file it will have a new text.
I want to do that without additional files. Can it be done using only javascript in the header? If yes, how?