简体   繁体   English

如何使用Phonegap和javascript在iPhone上隐藏和显示键盘

[英]How to hide and show the keyboard on an iPhone using Phonegap and javascript

In my Phonegap application, I have one screen where if the user taps or clicks outside of the textarea, the keyboard should hide. 在我的Phonegap应用程序中,我有一个屏幕,如果用户在文本区域之外单击或单击,则键盘应隐藏。 I used the .blur( function, but by doing that the screen goes up and the user can't see the application bar on the top (the screen itself doesn't move though). 我使用了.blur(函数,但是这样做会使屏幕上升,并且用户看不到顶部的应用程序栏(尽管屏幕本身不会移动)。

After calling blur, try window.scrollTo(0,0) . 调用blur之后,尝试window.scrollTo(0,0)

If I recall correctly, you might have to wrap it in a 0ms setTimeout 如果我没记错的话,您可能需要将其包装在0ms setTimeout中

$('#someInput').blur();
setTimeout(function(){
  window.scrollTo(0, 0);
}, 0);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM