admin管理员组文章数量:1334339
Is there a way to have JavaScript hold any variables through a reload?
If the user hits the reload button, is there any state that is kept by JavaScript, once a page is reloaded?
Is there a way to have JavaScript hold any variables through a reload?
If the user hits the reload button, is there any state that is kept by JavaScript, once a page is reloaded?
Share edited May 29, 2012 at 23:22 Charles 51.4k13 gold badges106 silver badges144 bronze badges asked May 29, 2012 at 22:49 user656925user656925 3- 1 This is now the third time I've had to correct your spelling of javascript in the past few days. Please take more care when selecting tags! – Charles Commented May 29, 2012 at 23:22
- Indeed, you gained the ability to create new tags once you hit 1500 reputation. – Charles Commented May 30, 2012 at 17:04
- Possible duplicate of Global Variable usage on page reload – Liam Commented Jun 1, 2017 at 14:52
3 Answers
Reset to default 5Suggestions
- Cookie
- HTML 5 Web Storage https://www.w3schools./html/html5_webstorage.asp
Either way, you'll need to write your own read/write methods to store your state.
You will have to utilize cookies to maintain your state. If you're using jQuery I sugest you look into jQuery Cookie:
https://github./carhartl/jquery-cookie
Hope this helps you!
small data (2KByte) can be stored in the URL suffix
fragment ID: //host/path#fragment-id
query string: //host/path?query-string
the fragment-id-method is used here:
http://xkcd-map.rent-a-geek.de/
on every dragend-event, the URL is changed
to reflect the current position on the map
special chars mut be urlencode-d
related: hot reloading, reloadable code, figwheel.clj, react.js hot loader
本文标签: Can JavaScript maintain any state after a reloadStack Overflow
版权声明:本文标题:Can JavaScript maintain any state after a reload? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742265294a2443275.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论