解决 andoird 和 iphone 微信浏览器h5页面收起软键盘后页面留空白问题
发布日期:2021-05-12 18:05:10 浏览次数:11 分类:精选文章

本文共 779 字,大约阅读时间需要 2 分钟。

android 版本

function windowResize() {    const originalHeight = document.documentElement.clientHeight || document.body.clientHeight;    window.onresize = () => {        const resizeHeight = document.documentElement.clientHeight || document.body.clientHeight;        if (resizeHeight - 0 < originalHeight - 0) {            // 软键盘弹起时执行此处操作            doSomething();        } else {            // 软键盘收起时执行此处操作            this.adjustAndroidInput();        }    };} /***修复andoird 微信浏览器键盘收起后留空白的问题*/function adjustAndroidInput() {setTimeout(() => {document.activeElement.scrollIntoViewIfNeeded();}, 100);}

iphone 版本

function iosInputBlur() {    setTimeout(() => {        window.scrollTo({            top: 0,            left: 0,            behavior: 'smooth'        }, 100);    }, 100);}
上一篇:一行 css 实现竖直间隔线
下一篇:Flex 布局的自适应子项内容过长导致其被撑大问题

发表评论

最新留言

逛到本站,mark一下
[***.202.152.39]2025年04月05日 21时21分54秒