本文介绍了默认按钮类型是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我这样做:

<button name="Save">Save</button>

我能保证它在所有浏览器上的表现都是一样的吗?

can I be assured that it will behave the same way across all browsers?

推荐答案

对于大多数浏览器,button 的默认 typesubmit.

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 及更低版本,其中默认 typebutton.

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 上有多个 buttonbutton 被传递而不是 value),您可能可以避免为 button 提供 type 属性.

If old IE support is not an issue (older versions of IE also have trouble with multiple buttons 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.

这篇关于默认按钮类型是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-05 09:50