最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

jquery - JavaScript Temporary Storage - Stack Overflow

programmeradmin1浏览0评论

I am writing a Quiz Application and require JavaScript mechanisms to temporarily store data without utilizing MySQL or an Internet Connection. The Game is a Standalone application. What techniques or libraries may be useful for such an application to store game data temporarily in the particular instance of running the JS functionality.

Please provide any references that may be useful.

Much appreciated

I am writing a Quiz Application and require JavaScript mechanisms to temporarily store data without utilizing MySQL or an Internet Connection. The Game is a Standalone application. What techniques or libraries may be useful for such an application to store game data temporarily in the particular instance of running the JS functionality.

Please provide any references that may be useful.

Much appreciated

Share Improve this question asked Sep 25, 2014 at 2:18 MpatapoMediaMpatapoMedia 111 silver badge11 bronze badges 2
  • 3 You can use localStorage. – jpcanamaque Commented Sep 25, 2014 at 2:20
  • Just answered a similar question today: stackoverflow./a/26026430/965907 – Shomz Commented Sep 25, 2014 at 2:20
Add a ment  | 

3 Answers 3

Reset to default 3

If you don't need your data to stay after you leave the page, consider using sessionStorage.

Otherwise, you're fine with localStorage, like I said in the ment, here is a very related answer: https://stackoverflow./a/26026430/965907

You can use cookies, but localStorage is a bit more modern and provides several advantages. See https://developer.mozilla/en-US/docs/Web/Guide/API/DOM/Storage for a list of storage options in modern browsers.

localStorage and sessionStorage are very similar, and I'd suggest you just use localStorage. See HTML5 Local storage vs. Session storage for a broader discussion.

Maybe you can use javascript cookies. With them you can keep information with a name for as long as you would like. sessionStorage and localStorage are harder to understand and add to your page, but if you are an expert then you could use those. But as I said, I would remend using cookies.
Good luck with your work!

发布评论

评论列表(0)

  1. 暂无评论