zoukankan      html  css  js  c++  java
  • IOS处理点空白处不自动失去焦点的问题

    objBlurFun("input");
        //如果不是当前触摸点不在input上,那么都失去焦点
        function objBlurFun(sDom,time){
            var time = time||300;
            //判断是否为苹果
            var isIPHONE = navigator.userAgent.toUpperCase().indexOf("IPHONE")!= -1;
            if(isIPHONE){
               var obj = document.querySelectorAll(sDom);
               for(var i=0;i<obj.length;i++){
                   objBlur(obj[i],time);
               }
            }
        }    
        // 元素失去焦点隐藏iphone的软键盘
        function objBlur(sdom,time){
             if(sdom){
                sdom.addEventListener("focus", function(){
                        document.addEventListener("touchend", docTouchend,false);
                },false);
                    
             }else{
                 throw new Error("objBlur()没有找到元素");
             }
             var docTouchend = function(event){
                if(event.target!= sdom){
                    setTimeout(function(){
                         sdom.blur();
                        document.removeEventListener('touchend', docTouchend,false);
                    },time);
                }
             };
            
        }
  • 相关阅读:
    并发编程
    网络与WEB 编程
    包和模块
    元编程
    类和对象
    【算法题 14 LeetCode 147 链表的插入排序】
    剑指offer面试54题
    剑指offer 面试51题
    剑指offer 面试3题
    剑指offer 面试52题
  • 原文地址:https://www.cnblogs.com/binmengxue/p/5993166.html
Copyright © 2011-2022 走看看