js控制移动浏览器输入框获取焦点隐藏不弹出系统软键盘

  使用移动端浏览器看网页时,输入对象获取焦掉后会自动弹出系统的软键盘,导致页面显示区域变小,如何禁止输入对象input获取焦点后的系统软键盘。

 

  js控制移动浏览器输入框获取焦点隐藏不弹出系统软键盘源代码如下

<input type="text" id="phone-number" onfocus="blur();" />

  意思就是获取焦点后马上取消焦点,这样软键盘就会自动隐藏了。下面是老外的说明

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.

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

  http://stackoverflow.com/questions/10940287/html-mobile-forcing-the-soft-keyboard-to-hide

 

  有这种js控制移动浏览器输入框获取焦点隐藏不弹出系统软键盘要求的,一般是输入框使用了自己写的软键盘,而不需要调用系统的软键盘。

这里推荐下自己写的居于jquery的软键盘:jQuery软键盘插件

加支付宝好友偷能量挖...


原创文章,转载请注明出处:js控制移动浏览器输入框获取焦点隐藏不弹出系统软键盘

评论(0)Web开发网
阅读(1466)喜欢(0)JavaScript/Ajax开发技巧