在 html 中隐藏输入的长度是否有一个最大值?

换句话说:

<input type="hidden" value="Can I put as much as I want in here, or is there a limit?" />

如果是,那是什么?

69382 次浏览

It depends on the method you send the form with.

With GET, there is a commonly agreed on limit of about 1-2 kilobytes, depending on browser and server limitations.

With POST, there is no technical limit in the browser, but usually one on the server side - see e.g. Apache's LimitRequestBody, PHP's post_max_size and so on.

Warning! I have experienced problems with <input type="text"> when text is longer than 65535 (max signed int size)

Pasting the text seems to cause some weird overflow of content. Spotted in webkit.

[edit]

The size of GET request is not exactly limited the way Pekka wrote. There is a limit of 2083 bytes for the whole GET query string address?params in Internet Explorer only In other browsers there is practically no limit, with FireFox sending GET queries of over 100KB for example. Obviously the server has to allow those.

It's not covered in documentation, so one has to test it to know the limits for other browsers. IE: http://support.microsoft.com/kb/208427