HTML Mobile - 强制隐藏软键盘 [英] HTML Mobile -forcing the soft keyboard to hide

查看:22
本文介绍了HTML Mobile - 强制隐藏软键盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为一家优惠券公司开发前端网站,我有一个页面,用户只需输入电话号码和花费的 $$.我们想出了一个用 Javascript 构建的有趣的屏幕键盘,它易于使用且速度快.但是,我正在寻找一种解决方案来阻止软键盘在用户聚焦并在这些字段中输入文本/数字时弹出.

I am developing the front end site for a coupon company, and I have a page where the user only needs to input phone number and $$ spent. We came up with a fun on-screen keyboard built in Javascript, that is easy to use, and fast. However, I am looking for a solution to stop the soft keyboard from popping when the user focuses and enters text/numbers in those fields.

我知道 HTML5 提出的号码/电话/电子邮件"类型属性.然而,冒着听起来很疯狂的风险,我真的只想使用我的屏幕键盘.

I know about the "number/phone/email" type attributes that HTML5 came up with. However, at the risk of sounding crazy, I really want to just use my on-screen keyboard.

注意:本网站主要面向平板电脑.

Note: this web site is mostly targeted to tablets.

谢谢.

推荐答案

由于软键盘是操作系统的一部分,通常情况下,您将无法隐藏它 - 同样,在 iOS 上,隐藏键盘从元素上删除焦点.

Since the soft keyboard is part of the OS, more often than not, you won't be able to hide it - also, on iOS, hiding the keyboard drops focus from the element.

但是,如果您在输入上使用 onFocus 属性,然后 blur() 立即输入文本,键盘将隐藏自身和 onFocus 事件可以设置一个变量来定义最后关注哪个文本输入.

However, if you use the onFocus attribute on the input, and then blur() the text input immediately, the keyboard will hide itself and the onFocus event can set a variable to define which text input was focused last.

然后更改页面键盘以仅更改最后一个焦点(使用变量检查)文本输入,而不是模拟按键操作.

Then alter your on-page keyboard to only alter the last-focused (check using the variable) text input, rather than simulating a key press.

这篇关于HTML Mobile - 强制隐藏软键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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