<html>
<head>
<title>localStorage Demo</title>
<script>
function savetext () {
var s = document.getElementById ("idTextarea").value;
if (s != localStorage.savedtext) {
localStorage.savedtext = s;
}
document.getElementById ("idCharCount").innerHTML = s.length;
}
function startup () {
if (typeof (Storage) == undefined) {
document.getElementById ("idCaveat").innerHTML = ", which unfortunately is not available in this browser";
}
else {
if (localStorage.savedtext == undefined) {
localStorage.savedtext = "";
}
document.getElementById ("idTextarea").value = localStorage.savedtext;
self.setInterval (function () {savetext ()}, 1000);
}
}
</script>
<style>
textarea {
font-size: 16px;
line-height: 130%;
margin-top: 7px;
width: 700px;
height: 200px;
rows: 15;
cols: 80;
}
</style>
</head>
<body>
<textarea id="idTextarea"></textarea>
<span id="idCharCount"></span>
<script> startup ();</script>
</body>
</html>