最好的办法对于后退按钮离开表单数据 [英] Best Way For Back Button To Leave Form Data

查看:88
本文介绍了最好的办法对于后退按钮离开表单数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我基于从一种形式的用户输入创建web页面。用户看到生成的页面后,我希望让他们到preSS后退按钮并更改到窗体。我想显示的形式,他们已经pviously填出来$ P $。是什么让这种行为(跨浏览器支持)的最佳方式?


解决方案

  

用户看到生成的页面我想要让他们到preSS后退按钮并更改表格后。我想显示的形式,他们已经填写出来previously。


有没有必要添加任何花哨的巧妙code;这就是浏览器将默认情况下做的,除非你采取prevent它,比如积极的措施:


  • 破缓存,缓存控制/编译指示头

  • 从响应POST产生自身的表单页面(而不是使用POST-重定向-GET)

  • 从脚本生成的表单元素

Cookie的解决方案是脆弱的,需要特殊处理,如果你不想要两个选项卡中打开一次变得非常混乱。很容易让自己:让浏览器做的工作。

I'm creating a web page based on user input from a form. After the user sees the generated page I want to allow them to press the back button and make changes to the form. I would like to display the form as they had filled it out previously. What is the best way to get this behavior (with cross browser support)?

解决方案

After the user sees the generated page I want to allow them to press the back button and make changes to the form. I would like to display the form as they had filled it out previously.

There is no need to add any clever fancy code; that is what browsers will do by default, unless you take active steps to prevent it, such as:

  • breaking the cache with Cache-Control/Pragma headers
  • generating the form page itself from the response to a POST (use POST-Redirect-GET instead)
  • generating the form elements from script

Cookie solutions are fragile and need special handling if you don't want two tabs open at once to get very confused. Make it easy for yourself: let the browser do the work.

这篇关于最好的办法对于后退按钮离开表单数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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