Consider two web pages with the following in their body respectively:
<body>
<script>
document.writeln('<textarea></textarea>')
</script>
</body>
and
<body>
<script>
var t = document.createElement('textarea');
document.body.appendChild(t);
</script>
</body>
(think of them as part of something larger, where the textareas have to be generated from JavaScript and can't be hard-coded into the page). They both produce the same output, but the former is considered "bad", while the latter is considered the "right" way to do it. (Right?)
On the other hand, if you type something in the page and then either refresh it, or go somewhere else and hit Back, then in the former case, what you typed in the textarea is preserved, while in the later it is lost. (At least on Firefox.)
Is there a way to use the latter method and still have the useful feature that what the user has typed into a form is saved even if they accidentally hit refresh or come back via the Back button (at least on Firefox)?