HTML5 localstorage如何工作? [英] How does HTML5 localstorage work?

查看:112
本文介绍了HTML5 localstorage如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须创建一个应用程序,用户可以根据用户名和密码获取一些数据。

I have to create one application in which the user is to get some data based on his username and passsword.

是否可以为网站的多个HTML页面创建单个持久性本地存储?每次页面加载时是否必须插入记录?我的期望是为多个用户插入一次记录。任何人都可以帮忙吗?

Is it possible to create single persistant local storage for multiple HTML pages of a website? Do I have to insert records everytime the page loads? My expectation is that inserting records one time for multiple users. Can anyone help?

推荐答案

是的,存储位于域级别,因此您无需刷新或重新在页面加载时填充数据。它也会在会话中存活,但请记住,所有内容都是键/值对存储为字符串,因此当您将其读回时需要解析它(JSON.parse()) ;

Yes, the storage is at domain level so you don't have to 'refresh' or re-populate the data on page load. It'll also survive sessions too, but remember that everything is a key/value pair stored as a string so you'll need to parse it when you read it back out (JSON.parse());

这篇关于HTML5 localstorage如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆