< input type ="隐藏">的原始目的 [英] Original purpose of <input type="hidden">?

查看:139
本文介绍了< input type ="隐藏">的原始目的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很好奇< input type =hidden> 标记的原始目的。



<现在,它经常与JavaScript一起用于存储发送到服务器的变量以及类似的东西。





因此, code>< input type =hidden> 存在之前 JavaScript,那么它的原始目的是什么?我只能想象从服务器向客户端发送一个值(未发送),以保持一种状态。或者在它的历史记录中出现错误,并且< input type =hidden> 总是应该与JavaScript一起使用?



如果可能的话,请在您的答案中提供参考。

解决方案

我只能想象从服务器向客户端发送一个值(不变)返回以维持某种状态。


准确地说。事实上,它今天仍然用于这个目的,因为我们今天所知道的HTTP仍然是,至少从根本上说,是一个无状态协议。

这个用例实际上是第一个如 HTML 3.2 所述(我很惊讶HTML 2.0不包含这样的描述) p>


type = hidden

这些字段不应该呈现,为服务器提供一种用表单存储状态信息的手段。当提交表单时,这将使用由相应属性定义的名称/值对来传递回服务器。这是HTTP的无状态工作。

 < input type = hidden name = customerid value =c2415-345- 8563\" > 


值得一提的是,HTML 3.2仅仅成为W3C推荐标准< 在JavaScript的初始版本之后,假设隐藏字段几乎总是具有相同的用途是安全的。


I am curious about the original purpose of the <input type="hidden"> tag.

Nowadays it is often used together with JavaScript to store variables in it which are sent to the server and things like that.

Therefore, the <input type="hidden"> existed before JavaScript, so what was its original purpose? I can only imagine of sending a value from the server to the client which is (unchanged) sent back to maintain a kind of a state. Or do I get something wrong in the history of it and <input type="hidden"> was always supposed to be used together with JavaScript?

If possible, please also give references in your answers.

解决方案

I can only imagine of sending a value from the server to the client which is (unchanged) sent back to maintain a kind of a state.

Precisely. In fact, it's still being used for this purpose today because HTTP as we know it today is still, at least fundamentally, a stateless protocol.

This use case was actually first described in HTML 3.2 (I'm surprised HTML 2.0 didn't include such a description):

type=hidden
These fields should not be rendered and provide a means for servers to store state information with a form. This will be passed back to the server when the form is submitted, using the name/value pair defined by the corresponding attributes. This is a work around for the statelessness of HTTP. Another approach is to use HTTP "Cookies".

<input type=hidden name=customerid value="c2415-345-8563">

While it's worth mentioning that HTML 3.2 became a W3C Recommendation only after JavaScript's initial release, it's safe to assume that hidden fields have pretty much always served the same purpose.

这篇关于&lt; input type =&quot;隐藏&quot;&gt;的原始目的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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