单击浏览器上的后退按钮时会丢失表单数据

编程入门 行业动态 更新时间:2024-10-26 08:21:45
本文介绍了单击浏览器上的后退按钮时会丢失表单数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

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

谢谢

解决方案

当后退按钮被点击时,浏览器的行为会有所不同 - 这种行为主要取决于用户的隐私设置。另外,大多数浏览器在按下通过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.

更多推荐

单击浏览器上的后退按钮时会丢失表单数据

本文发布于:2023-06-06 10:49:26,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/539015.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:时会   表单   单击   按钮   器上

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!