Html 表单和移动网络浏览器问题
移动键盘(Android iPhone)没有选项卡按钮。这就是为什么当按下回车键时本机应用程序会转到下一个字段。然而,当按下回车键时,浏览器表单就会被提交。
我该如何解决这个问题?
Mobile keyboard (Android IPhone) has no tab button. That is why native application go to next field when enter is pressed. However browser forms are submitted when enter is pressed.
How can I solve this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用
tabindex
正确,它应该像本机应用程序一样工作。顺便说一句,至少在 Android 上,原生应用不需要做任何特殊的事情来获得这种行为(最多他们必须指定
nextFocusForward
,如果布局太复杂而 Android 无法做到)自己弄清楚)。Use
tabindex
properly and it should work just like with native applications.By the way, on Android at least, native apps don't have to do anything special to get this behavior (at most they have to specify
nextFocusForward
, if the layout is too complicated and Android can't figure that out by itself).我假设您正在谈论屏幕键盘。 iPhone 将显示上一页 | Next 作为网络表单中的键盘配件。安卓也会。
如果他们不这样做,那么您的标记可能有问题。您可以发布您的表单 HTML 代码吗?
我还想说nLL的建议是正确的。这会让它感觉更加光滑。
I assume you're talking about the on-screen keyboard. iPhone will show
Previous | Next
as a keyboard accessory in web forms. Android will too.If they don't then something might be wrong with your markup. Is it possible for you to post your form HTML code?
I would also say that nLL's suggestion is correct. It will make it feel more polished.
由于您的目标是高端手机,您可以使用简单的 JavaScript 处理 Enter 键
since you are targeting high-end phones you can handle enter key with simple JavaScript