js---安卓手机软键盘遮挡输入框问题

在移动端中,部分安卓手机遇到输入框被软键盘遮挡问题。

解决方法:

           //如果是安卓手机,添加获得焦点的滚动事件

            if (/Android/gi.test(navigator.userAgent)){

                window.addEventListener('resize', function() {

                    if (document.activeElement.tagName == 'INPUT'|| document.activeElement.tagName == 'TEXTAREA') {

                        window.setTimeout(function() {

                            document.activeElement.scrollIntoViewIfNeeded();

                        }, 0);

                    }

                });

            }

原文地址:https://www.cnblogs.com/Super-scarlett/p/12187870.html