将表单数据保留在浏览器的后退或前进位置
我遇到的问题是,当用户后退或前进时,某些浏览器会丢失数据。例如,Firefox 大多数时候都是从缓存加载,所以没问题,但 Chrome 每次都会重新初始化表单!
我现在将数据保存在 cookie 中并将其加载回来。但这不仅仅是一种形式,而且形式很大,有时 cookie 的大小还不够。找不到任何其他方法来做到这一点...
你能给我一些建议并帮助我解决这个问题吗?提前致谢。
The problem that I have is that some browsers loses data, when a user hits back or forward. Firefox for example, most of the times, loads from cache, so it's OK, but Chrome reinits the form every time!
I am now keeping the data in a cookie and load them back. But it's not only one form and the forms are big and sometimes, the cookie's size is not enough. Couldn't find any other way to do this...
Can you suggest me something and help me solve this?? Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以尝试会话变量。 cookie的值存储在客户端的cookie文件夹中,但Session数据存储在客户端。它比饼干更轻。
You can try session variable. Value of cookies are stored in client side cookie folder, but Session data stored in client side. It is more light weight then cookies.
您可以使用 AJAX 将值发送到服务器(可能每隔一段时间或在页面卸载之前),将它们存储在会话中,并在用户返回表单时使用 AJAX 检索它们。
You could use AJAX to send the values to your server (perhaps on an interval, or before a page unload), store them in the session, and retrieve them with AJAX when the user goes back to the form.
可以做的事情如下。在 HTML 页面中,确保将 HttpSession 变量设置为 true 。
这可以通过以下方式完成
what could be done is as follows . In your HTML page make sure you set the HttpSessionvariable true .
This can be done by the following