问题描述
如果我这样做:
<button name="Save">Save</button>
我能保证它在所有浏览器上的表现都是一样的吗?
can I be assured that it will behave the same way across all browsers?
推荐答案
对于大多数浏览器,button
的默认 type
是 submit
.
For most browsers the default type
of button
is submit
.
type = submit|button|reset [CI]
该属性声明按钮的类型.可能的值:
This attribute declares the type of the button. Possible values:
submit:创建一个提交按钮.这是默认值.
submit: Creates a submit button. This is the default value.
(http://www.w3.org/TR/html401/interact/forms.html#h-17.5)
唯一的例外是 IE7 及更低版本,其中默认 type
是 button
.
The only exception to this is IE7 and below where the default type
is button
.
Windows Internet Explorer 8 及更高版本.该属性的默认值取决于当前的文档兼容模式.在 IE8 标准模式下,默认值为提交.在其他兼容模式和早期版本的 Windows Internet Explorer 中,默认值为按钮.
(https://msdn.microsoft.com/en-us/library/ms534696(v=vs.85).aspx)
如果旧的 IE 支持不是问题(旧版本的 IE 在一个 form
上有多个 button
和button
被传递而不是 value
),您可能可以避免为 button
提供 type
属性.
If old IE support is not an issue (older versions of IE also have trouble with multiple button
s on one form
and the text of thebutton
being passed through instead of thevalue
) you can probably get away with not supplying the type
attribute for a button
.
这篇关于默认按钮类型是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!