gpt4 book ai didi

ios - 如何使用 phonegap 防止键盘在 iOS 应用程序上推 webview

转载 作者:IT王子 更新时间:2023-10-29 08:13:40 24 4
gpt4 key购买 nike

当屏幕底部的输入字段获得焦点时,键盘将我的 webview 向上推,页面的上半部分不再可见。

我想防止键盘推高 webview。

有人有想法吗?

最佳答案

在焦点上,设置 window.scrollTo(0,0); 这可以防止键盘完全推高 webview

$('input').on('focus', function(e) {
e.preventDefault(); e.stopPropagation();
window.scrollTo(0,0); //the second 0 marks the Y scroll pos. Setting this to i.e. 100 will push the screen up by 100px.
});

如果您不想为 Y 滚动位置设置静态值,请随意使用 short plugin I've written that automatically aligns the keyboard underneath the input field .它并不完美,但可以完成工作。只需将其称为焦点,如上所示:

setKeyboardPos(e.target.id);

关于ios - 如何使用 phonegap 防止键盘在 iOS 应用程序上推 webview,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13820088/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com