disabled =“disabled”和“disabled”之间有什么区别?和readonly =“readonly”用于HTML表单输入字段? [英] What's the difference between disabled="disabled" and readonly="readonly" for HTML form input fields?
问题描述
我已经阅读了一点,但我似乎没有找到任何坚实的不同的浏览器处理事情。我正在建立一个应用程序,必须符合第508节(屏幕阅读器可访问),并清除回IE 6。
I have read a bit on this, but I can't seem to find anything solid about how different browsers treat things. I'm building an app that has to be Section 508-compliant (screen-reader accessible) and work clear back to IE 6.
推荐答案
readonly
元素只是无法编辑,但是当形式
提交时会发送。 disabled
元素不可编辑,不会在提交时发送。另一个区别是 readonly
元素可以关注(并且通过表单标签时获得关注)而 disabled
元素不能。
a readonly
element is just not editable, but gets sent when the according form
submits. a disabled
element isn't editable and isn't sent on submit. another difference is that readonly
elements can be focused (and getting focused when "tabbing" through a form) while disabled
elements can't.
请阅读这篇精彩文章或 w3c 。引用重要部分:
read more about this in this great article or the definition by w3c. to quote the important part:
主要区别
已停用的属性
- 禁用的表单元素的值不会传递给处理器方法。 W3C称这是一个成功的元素(这与
形式的复选框类似,但未选中。) - 某些浏览器可能会覆盖已禁用的表单元素或为其提供默认样式。
- 禁用表单元素无法获得焦点。
- 已禁用的表单元素在标签导航中被跳过。
- Values for disabled form elements are not passed to the processor method. The W3C calls this a successful element.(This works similar to form check boxes that are not checked.)
- Some browsers may override or provide default styling for disabled form elements. (Gray out or emboss text) Internet Explorer 5.5 is particularly nasty about this.
- Disabled form elements do not receive focus.
- Disabled form elements are skipped in tabbing navigation.
只读属性
- 并非所有表单元素都具有只读属性。最值得注意的是,
< SELECT>
,< OPTION>
和< BUTTON> ;
元素没有readonly
属性(虽然你们都禁用了属性) - 浏览器不提供默认的覆盖视觉反馈,只要。 (这可能是一个问题...见下文。)
- 具有readonly属性集的表单元素将传递给表单处理器。
- 表单元素可以接收焦点
- 只读表单元素包含在标签式导航中。
- Not all form elements have a readonly attribute. Most notable, the
<SELECT>
,<OPTION>
, and<BUTTON>
elements do not have readonly attributes (although thy both have disabled attributes) - Browsers provide no default overridden visual feedback that the form element is read only. (This can be a problem… see below.)
- Form elements with the readonly attribute set will get passed to the form processor.
- Read only form elements can receive the focus
- Read only form elements are included in tabbed navigation.
这篇关于disabled =“disabled”和“disabled”之间有什么区别?和readonly =“readonly”用于HTML表单输入字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!