github: comment will be remaining even if reload browser, why?

旧街凉风 提交于 2019-12-01 16:33:21

They are using SessionStorage to do this:

On Page Leave:

  1. select all of the input fields with .js-session-resumable as selector
  2. put {id, value} pair of inputs in an array
  3. put it in SessionStorage as session-resume:/current/page/path

On Page Load:

  1. check if there are any values with session-resume:/current/page/path key in SessionStorage
  2. if yes, update values of inputs and remove this record from SessionStorage

Note: If you write a comment in a page (without submitting it) and go to another page, then you can see your comment saved in SessionStorage.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!