Chrome浏览器不缓存浏览器历史记录中使用的隐藏表单字段值 [英] Chrome doesn't cache hidden form field values for use in browser history

查看:420
本文介绍了Chrome浏览器不缓存浏览器历史记录中使用的隐藏表单字段值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含文本框字段和隐藏字段的ASP.Net web表单。隐藏字段值使用客户端JavaScript动态修改。发布表单,检查这些值并重定向到另一个页面都是按预期工作。

然而,当我使用浏览器后退按钮来显示前一页时,我期望所以看到所有的表单字段仍然填充了发布的值。



在IE和Firefox中,文本和隐藏输入字段都是这种情况。



在Chrome中,这仅限于文本字段。隐藏字段的值会丢失。



在导航浏览器历史记录时,Chrome从不重新填充动态设置隐藏表单字段值吗?



我已经将一个小样本放在一起来演示问题,并可以根据需要提供。我想先问这个问题,看看这是否是众所周知的行为以及我必须接受的事情。 你不应该依靠这种行为。在浏览器中,即使在浏览器版本中也是如此。这种行为在任何标准中都没有描述。如果您希望您的字段具有特定的值,则可以使用Cookie,或者在页面加载时始终向服务器发出请求,或者使用更本地化的方法,例如本地存储(尽管它并未得到广泛支持)。


I have a ASP.Net web form that contains both text box fields and hidden fields. The hidden field values are modified dynamically using client side JavaScript. Posting the form, inspecting the values and redirecting to another page is all working as expected.

However, when I use the browser back button to display the previous page then I expect so see that ALL form fields are still populated with the values that were posted.

In IE and Firefox this is the case for both text and hidden input fields.

In Chrome this is ONLY the case for text fields. The value of hidden fields is lost.

Is it true that Chrome never repopulates dynamically set hidden form field values when navigating the browser history?

I have put a small sample together to demonstrate the problem and can provide that if required. I wanted to first ask the question to see if this is well known behaviour and something I have to accept.

解决方案

You should not rely on this behavior. It is different among browsers, even among browser versions. This behavior is not described in any standards. If you want your fields to have specific values, you can use cookies, or always make requests to the server when page loads, or use more modern methods like local storage (it is not widely supported though).

这篇关于Chrome浏览器不缓存浏览器历史记录中使用的隐藏表单字段值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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