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

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

问题描述

我想从一个HTML页面发送一些数据到另一个。我通过查询参数(如 http://localhost/project/index.html?status = exist )发送数据。这种方法的问题是数据保留在URL中。有没有其他方法可以通过使用JavaScript或jQuery的HTML页面发送数据。为什么不将值存储在HTML5存储对象中,例如 sessionStorage

解决方案 $ c>或 localStorage ,请访问 HTML5存储文档获取更多细节。使用此功能,您可以暂时/永久性地在本地存储中间值,然后再访问您的值。



存储会话的值:

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

或更多永久性:

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

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


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.

解决方案

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.

To store values for a session:

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

or more permanently:

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

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天全站免登陆