zoukankan      html  css  js  c++  java
  • 移动端,由页面定位的滚动区域引起光标可以跟页面滑动

    var isIPHONE = navigator.userAgent.toUpperCase().indexOf('IPHONE')!= -1;
    
    // 元素失去焦点隐藏iphone的软键盘
    
    function objBlur(obj,time){
        var that;
    //  if(typeof id != 'string') throw new Error('objBlur()参数错误');
            time = time || 100,
            docTouchend = function(event){
                    if(event.target!= obj){
                        setTimeout(function(){
                            if (typeof($(event.target).attr("readonly"))!=="undefined") {
                                obj[that].blur();
                                document.removeEventListener('touchend', docTouchend,false);
                                return false;
                            }
                        },time);
                    }
            };
            if(obj){
                for (var i = 0; i<obj.length; i++) {
                    obj[i].index = i;
                    obj[i].addEventListener('focus', function(){
                        that = this.index;
                        document.addEventListener('touchend', docTouchend,false);
                    },false);
                }
            }else{
                throw new Error('objBlur()没有找到元素');
            }
    }
    
    

    调用

    $(function () {
        if(isIPHONE){
            var obj = document.getElementsByTagName('input');
            var input = new objBlur(obj);
            input=null;
        }
    })
    
    

    说明:焦点在某个input元素上,此时快速滑动页面,由于是absolute定位,光标跟不上滚动的速度。导致错位问题。解决方案就是在你滑动页面的时候直接让input失去焦点,隐藏光标。

  • 相关阅读:
    struts2 的特征
    The method getJspApplicationContext(ServletContext) is undefined for the type JspFactory
    web.xml 404 500 配置
    重大发现 springmvc Controller 高级接收参数用法
    struts2 file
    struts2-core-2.3.20.jar
    系统设计工具
    Java基础
    IAM
    秒杀系统
  • 原文地址:https://www.cnblogs.com/lisaShare/p/10328265.html
Copyright © 2011-2022 走看看