Questa è l'unica soluzione. Quando chiudi e riapri ti comparirà il testo precedentemente immesso (ma dipende dai browsers)…
codice:
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Pagina vuota</title>
<script type="text/javascript">
function updateLink() {
document.getElementById("notesLink").setAttribute("href", "data:text\/plain;charset=utf-8," + escape(document.notesForm.notesArea.value));
document.getElementById("notesFile").setAttribute("href", "data:application\/bin;charset=utf-8," + escape(document.notesForm.notesArea.value));
}
function readData() {
if (localStorage.hasOwnProperty("myNotes")) { document.notesForm.notesArea.value = localStorage.getItem("myNotes"); }
updateLink();
}
window.onload = readData;
window.onunload = function() { localStorage.setItem("myNotes", document.notesForm.notesArea.value); };
</script>
</head>
<body>
<form name="notesForm">
<textarea name="notesArea" rows="15" cols="50" onblur="updateLink();"></textarea></p>
[ Scarica file di testo | Apri file di testo ]</p>
</form>
</body>
</html>