为什么输入524288的默认最大长度? [英] Why is the default max length for an input 524288?

查看:187
本文介绍了为什么输入524288的默认最大长度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HTML输入的默认最大长度(< input type =text> )为 524288 字符。这似乎是一个非常奇怪的数字,为什么选择它? 根据 w3c 最大值不受限制:


maxlength = number [CN]



当type属性的值为text或password时,该属性指定最大字符数用户可以输入。该数字可能超过指定的大小,在这种情况下,用户代理应该提供滚动机制。 此属性的默认值是无限制的数字。


尽管如此,我注意到在Chrome实际上默认 maxlength 为524288,这对我来说似乎是一个'错误',或者至少是一个有意的选择,将输入限制为512KB(感谢 Benjamin Udink ten Cate 指出了这一点)。


The default maximum length for a HTML input (<input type="text">) is 524288 characters. That seems like a very peculiar number, why was it chosen?

解决方案

According to the w3c the maximum value is unlimited:

maxlength = number [CN]

When the type attribute has the value "text" or "password", this attribute specifies the maximum number of characters the user may enter. This number may exceed the specified size, in which case the user agent should offer a scrolling mechanism. The default value for this attribute is an unlimited number.

Despite that, I have noticed that in Chrome indeed defaults the maxlength to 524288, which seems a 'bug 'to me, or at least a deliberate choice to cap the input to 512KB (thanks to Benjamin Udink ten Cate for pointing that out).

这篇关于为什么输入524288的默认最大长度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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