单击浏览器上的后退按钮时会丢失表单数据 [英] Losing form data when clicking the back button on browser

查看:120
本文介绍了单击浏览器上的后退按钮时会丢失表单数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我点击任何浏览器时,我会丢失表单中输入的所有数据,包括下拉式和文本输入类型。

这是服务器,浏览器还是编码问题?

谢谢

解决方案

当后退按钮被点击时,浏览器的行为会有所不同 - 这种行为主要取决于用户的隐私设置。另外,大多数浏览器在按下通过HTTPS连接查看的页面时会自动重置表单,而不管它们是否具有HTTP连接的正常行为。另外,许多依赖AJAX的HTML表单不能正确地或一致地恢复以前的状态。

编辑----



现在您提到使用PHP和MySQL,假设您也在使用会话......当您点击后退按钮时,浏览器不会预先填充表单。 PHP会话驱动的页面不会缓存在浏览器中,点击返回按钮返回上一页就像是从一开始就再次打开该页面 - 大多数浏览器不会麻烦恢复表单值。

When I click back on any browser I lose all the data which was inputted in the form on both drops downs and text input types.

Is this a server , Browser or a coding issue ?

Thanks

解决方案

Its a browser issue. Browser behave differently when the back button is clicked -- this behavior mostly depends on user privacy settings. In addition, most browsers will automatically reset form upon hitting back button for pages viewed over HTTPS connection regardless of their normal behavior for HTTP connections. In addition, many HTML forms that rely heavily on AJAX do not properly -- or consistently -- restore their previous state.

Edit ----

Now that you mention using PHP and MySQL, assuming that you are also using sessions... the browser will not pre-populate the form when you hit the back button. PHP-session powered pages are not cached in browsers and hitting back button to go back to previous page is just like opening that page again from the very beginning -- most browsers will not bother restoring the form values.

这篇关于单击浏览器上的后退按钮时会丢失表单数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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