用于 HTML 输入表单的 iOS 键盘中的 Go 与返回按钮 [英] Go vs. return button in iOS keyboard for HTML input forms

查看:34
本文介绍了用于 HTML 输入表单的 iOS 键盘中的 Go 与返回按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为 HTML 表单管理 iOS 键盘(在 UIWebView 中使用)是众所周知的,即 ;</input> 用于电话号码.

Managing the iOS keyboard for HTML <input> forms (used in UIWebView) is well known, i.e. <input type="tel"></input> for telephone numbers.

https://developer.apple.com/library/ios/documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/KeyboardManagement/KeyboardManagement.html

但我想知道键盘的蓝色开始"按钮.有时键盘有一个蓝色的'开始'按钮,有时键盘有一个灰色的返回按钮.有没有机会以编程方式控制这种行为?

But I was wondering about the keyboard's blue 'Go' button. Sometimes the keyboard has a blue 'Go' button, sometimes the keyboard has a gray return button. Is there any opportunity to control this behavior programmatically?

推荐答案

2020/2021 更新

正如 Cameron Cobb 指出的那样,Safari Mobile 支持新的 HTML 属性 enterkeyhint 自版本 13.7 ~ 2020 年 9 月(https://caniuse.com/mdn-html_global_attributes_enterkeyhint).

As Cameron Cobb pointed out, Safari Mobile supports the new HTML attribute enterkeyhint since version 13.7 ~ Sept. 2020 (https://caniuse.com/mdn-html_global_attributes_enterkeyhint).

以下值是可能的(https://mixable.blog/ux-improvements-enterkeyhint-to-define-action-label-for-the-keyboard-of-mobile-devices/):

<input enterkeyhint="enter">
<input enterkeyhint="done">
<input enterkeyhint="go">
<input enterkeyhint="next">
<input enterkeyhint="previous">
<input enterkeyhint="search">
<input enterkeyhint="send">


原答案

啊哈...

仅当 标签位于

标签内(并且表单标签有一个 action 属性).因此,如果您之后使用 JavaScript 访问表单元素,则可以省略 <form> 标签.

The 'Go' button is only shown, if the <input> tag is inside a <form> tag (and the form tag has an action attribute). So, if you access your form elements afterwards with i.e. JavaScript, you can omit <form> tags.

开始"按钮:

<form action="..." method="...">
   <input type="text"></input>
</form>

'返回'按钮:

<input type="text"></input>

这篇关于用于 HTML 输入表单的 iOS 键盘中的 Go 与返回按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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