javascript - Android 键盘隐藏文本输入

标签 javascript android angularjs jquery-mobile webview

我有一个使用 jQuery Mobile 的应用程序。

在 Chrome(Android 上)上进行测试时,当键盘打开时,位于页面底部的一些输入会自动移动到顶部。那是我期望的行为。

当我将此网站添加到我的 android 的主屏幕时,此行为不起作用,并且所有文本输入都被键盘隐藏。

我还注意到,当我在 Chrome 上再次打开相同的应用程序并重试基于 Webview 的应用程序后,现在一切正常。输入不再隐藏。

你见过这种错误吗?

提前致谢

最佳答案

我为您创建了一个演示,作为替代方案

我不得不附加一个空白框以在底部留出一些空间,然后在您关注输入时将输入向上移动到标题,因为它位于底部,因此没有滚动空间。

演示

https://jsfiddle.net/fyom081o/

代码

$(document).on("focus", "#text-basic", function(event){
    var boxheight =  $(window).height() - 40;
    $("#mycontntent").append("<div id='blank' style='height:"+boxheight+"px;'"+"></div>");
$('html, body').animate({scrollTop: $('#text-basic').offset().top - 100}, 500); 
});

$(document).on("focusout", "#text-basic", function(event){
$('#blank').remove();
});

关于javascript - Android 键盘隐藏文本输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31535898/

相关文章:

javascript - 添加类和删除类 JS 仅作用于页面中的一个 div。不适用于具有相同规范的其他人

javascript - 从 makefile 调用 node.js 失败

javascript - React 正在渲染 [Object object] 而不是数组内的 JSX 元素

android - xperia Z5 上的 LED 手电筒

javascript - Stripe 订阅 - Charing 3D Secure 卡号返回 subscription_payment_intent_requires_action

android - 如何在 android 中使用 intent 传递 parcelable 变量值?

android - 将 app bundle 上传到 google play 失败,没有提示

javascript - 使用 jQuery 更改 Angular 标签值

angularjs - Jasmine spyOn 没有考虑有 Angular 的垃圾

angularjs - 如何在另一个服务中从外部文件注入(inject)服务的模拟