Can JavaScript maintain any state after a reload? - Stack Overflow

Is there a way to have JavaScript hold any variables through a reload?If the user hits the reload butto

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
Add a ment  | 

3 Answers 3

Reset to default 5

Suggestions

  • 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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742265295a4411669.html

相关推荐

  • Can JavaScript maintain any state after a reload? - Stack Overflow

    Is there a way to have JavaScript hold any variables through a reload?If the user hits the reload butto

    22小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信