Go vs. return button in iOS keyboard for HTML inpu

2019-01-14 11:21发布

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?

2条回答
Rolldiameter
2楼-- · 2019-01-14 11:31

Aha...

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

'Go' button:

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

iOS 7.1 screenshot of keyboard

'return' button:

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

iOS 7.1 screenshot of keyboard

查看更多
来,给爷笑一个
3楼-- · 2019-01-14 11:32

The important part is that the form tag has an action property. (action="#" is a noop.)

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

return button

<form action="#">
  <input type="text" />
</form>

return button

查看更多
登录 后发表回答