您可以使用 JavaScript 显示/隐藏 iPad Safari 键盘吗?
是否可以通过代码控制iPad Safari中键盘的显示(显示/隐藏)?
我有 2 个表单字段; 1. 文本框(说出姓名) 2.选择列表/下拉菜单(说状态)
我的问题是,当用户将焦点从“名称”移动到“状态”时,键盘仍然在那里。为什么会这样?当焦点移动到下拉菜单时如何隐藏键盘?
谢谢。
Is it possible to control the display i.e.(show/hide) of keyboard in iPad Safari through code?
I have 2 form fields;
1. Text box (say Name)
2. Select list/Dropdown (Say State)
My question is when user moves focus from Name to State, the keyboard is still there..Why is it so and how can I hide the keyboard when focus moves to dropdown?
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我刚刚遇到了一个非常相似的问题,不确定我的解决方案是否适合您。
就我而言,我在表单中有一个文本输入。提交时,我使用
e.preventDefault()
来停止页面导航。我相信这也具有停止隐藏键盘的默认操作的效果。为了解决这个问题,我在提交表单时添加了显式的
input.blur()
。这似乎足以让 safari 去掉键盘了。希望这有帮助!
I just ran into a very similar problem, not sure if my solution will work for you.
In my case, I have a text input inside a form. On submit, I'm using
e.preventDefault()
to stop the page from navigating. I believe this was also having the effect of stopping the default action of hiding the keyboard.To solve this, I added an explicit
input.blur()
when the form is submitted. This seemed to be enough for safari to remove the keyboard.Hope this helps!
我有同样的问题。我有一个表单,当在字段外输入(不是 ipad 上的本机行为)和焦点选择字段时,键盘应该折叠。 创建隐藏输入
对我来说唯一的解决方案是为焦点事件
和 javascript 代码处理程序:如果您只想模糊输入字段,另一个解决方案可以完美工作,但在输入和选择之间它会失败
I had the same issue. I had a form were keyboard should be collapsed when type out of the field (not native behavior on ipad) and when focus select field. The only solution for me was creation of hidden input
and javascript code handler for focus event:
In case you want just to blur input field another solution works perfect, but between input and select it fails