How to implement Stack Overflow textarea that will restore your typing when asking a question after you close and reopen it
Implement it with HTML5 storage? Constantly upload to server session?
Which is a better a开发者_JS百科pproach?
HTML5 storage? Yes you can, but it won't be supported by old browsers. Another ways of doing that are:
- Store draft into cookies every n seconds.
- Store draft at server side using ajax requests every n seconds.
Or you could use one of these frameworks:
- PersistJS
- Sammy
- and many others (a quick search in github and google code should give you other anwsers)
They provide a persistent storage API in the browser, with various implementations/fallback dependening on the browser (cookie, localStorage, jquery data, adobe flash, google gears...)
精彩评论