在 iphone safari webapp 中隐藏键盘 [英] hide keyboard in iphone safari webapp

查看:36
本文介绍了在 iphone safari webapp 中隐藏键盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为 iPhone 创建一个基于 HTML/CSS/JS 的网络应用程序.我正在使用表单来接收输入并将数据传递给脚本,但我遇到的一个问题是键盘不会消失.用户将输入信息,点击提交,由于它是 JavaScript,页面不会重新加载.键盘保持原位,这很麻烦,并且为用户增加了另一个步骤(必须关闭它).

I'm creating a webapp for the iPhone, based in HTML/CSS/JS. I'm using forms to receive input and pass data to the script, but a problem I'm encountering is that the keyboard won't disappear. The user will enter the information, hit submit, and since it's JavaScript the page doesn't reload. The keyboard remains in place, which is a nuisance and adds another step for users (having to close it).

有没有办法强制 Safari 中的键盘消失?本质上,我有一种感觉,这个问题相当于问我如何强制输入框失去焦点或模糊.在网上看,我找到了很多检测模糊事件的例子,但没有一个例子可以强制发生这个事件.

Is there any way to force the keyboard in Safari to go away? Essentially, I have a feeling this question is equivalent to asking how I can force an input box to lose focus or to blur. Looking online, I find plenty of examples to detect the blur event, but none to force this event to occur.

推荐答案

更简单的是,您可以在当前聚焦的元素上调用 blur().$("#inputWithFocus").blur()

Even more simply, you can call blur() on the currently focused element. $("#inputWithFocus").blur()

这篇关于在 iphone safari webapp 中隐藏键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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