微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

html – 什么是默认按钮类型?

如果我这样做:
<button name="Save">Save</button>

我可以放心,它会在所有浏览器中表现相同吗?

解决方法

对于大多数浏览器,认类型的按钮是提交.

type = submit|button|reset [CI]

This attribute declares the type of the button. Possible values:

submit: Creates a submit button. This is the default value.

(http://www.w3.org/TR/html401/interact/forms.html#h-17.5)

唯一的例外是IE7及以下认类型为按钮的情况.

Windows Internet Explorer 8 and later. The default value of this attribute depends on the current document compatibility mode. In IE8 Standards mode,the default value is submit. In other compatibility modes and earlier versions of Windows Internet Explorer,the default value is button.

(https://msdn.microsoft.com/en-us/library/ms534696(v=vs.85).aspx)

如果旧的IE支持不是问题(IE的旧版本也有一个窗体上的多个按钮的问题,并且按钮的文本被传递而不是值),你可能会因为没有提供按钮的type属性而逃脱.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐