在 html 页面之间共享数据 [英] Share data between html pages

查看:54
本文介绍了在 html 页面之间共享数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将一些数据从一个 HTML 页面发送到另一个页面.我通过像 http://localhost/project/index.html?status=exist 这样的查询参数发送数据.这种方法的问题是数据保留在 URL 中.有没有其他方法可以使用 JavaScript 或 jquery 跨 HTML 页面发送数据.

I want to send some data from one HTML page to another. I am sending the data through the query parameters like http://localhost/project/index.html?status=exist. The problem with this method is that data remains in the URL. Is there any other method to send the data across HTML pages using JavaScript or jquery.

推荐答案

为什么不将值存储在 HTML5 存储对象中,例如 sessionStoragelocalStorage,请访问HTML5 存储文档 以获取更多详细信息.使用它,您可以在本地临时/永久存储中间值,然后稍后访问您的值.

why don't you store your values in HTML5 storage objects such as sessionStorage or localStorage, visit HTML5 Storage Doc to get more details. Using this you can store intermediate values temporarily/permanently locally and then access your values later.

要存储会话的值:

sessionStorage.getItem('label')
sessionStorage.setItem('label', 'value')

或更永久:

localStorage.getItem('label')
localStorage.setItem('label', 'value')

因此您可以使用 HTML5 存储对象在多个页面之间存储(临时)表单数据,您甚至可以在重新加载后保留这些数据..

So you can store (temporarily) form data between multiple pages using HTML5 storage objects which you can even retain after reload..

这篇关于在 html 页面之间共享数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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