问题描述
我开发的前端网站的优惠券的公司,我有一个页面,用户只需要输入电话号码和$$度过的。我们想出了一个有趣的屏幕上的键盘内置的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.
然而,如果你使用聚焦状态
属性输入,然后模糊()
文本输入,立即,键盘会隐藏自身和聚焦状态
事件可以设置一个变量来定义其文本输入的重点是最后一次。
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.
然后改变你对页的键盘只(使用变量检查)文本输入,而不是模拟的一个关键preSS改变过去为重点。
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移动-forcing软键盘隐藏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!