欢迎来到吴小小的专栏!

IOS弹出系统键盘后,页面不恢复

        <script>
            var u = navigator.userAgent, app = navigator.appVersion
            var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
            $(document).ready(function(){
                $("input").blur(function(){
                    if (isIOS) {
                        blurAdjust()
                    }
                });
            });
            // 解决苹果不回弹页面
            function blurAdjust(e){
                setTimeout(()=>{
                    if(document.activeElement.tagName == 'INPUT' || document.activeElement.tagName == 'TEXTAREA'){
                        return
                    }
                    let result = 'pc';
                    if(/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) { //判断iPhone|iPad|iPod|iOS
                            result = 'ios'
                    }else if(/(Android)/i.test(navigator.userAgent)) {  //判断Android
                            result = 'android'
                    }
                    
                    if( result = 'ios' ){
                        document.activeElement.scrollIntoViewIfNeeded(true);
                    }
                },100)
            }
        </script>
posted @ 2019-08-01 11:22  吴小小  Views(407)  Comments(0Edit  收藏  举报