zoukankan      html  css  js  c++  java
  • ios12.x等低版本系统输入框(input/textarea)拉起键盘后无法收回

    NO BB , SHOW ME CODE!

     1 objBlurFun("input");
     2 
     3 //如果不是当前触摸点不在input上, 那么都失去焦点
     4 function objBlurFun(el, time){
     5   const TIME = time || 300;
     6   //判断是否为苹果
     7   const ISIPHONE = navigator.userAgent.toUpperCase().indexOf("IPHONE") != -1;
     8   if(ISIPHONE){
     9     let obj = document.querySelectorAll(el);
    10     for(let i=0; i<obj.length; i++){
    11       objBlur(obj[i], TIME);
    12     }
    13   }
    14 }  
    15 
    16 // 元素失去焦点隐藏iphone系统软键盘
    17 function objBlur(el, time){
    18   if(el){
    19     el.addEventListener("focus", function(){
    20       document.addEventListener("touchend", docTouchend, false);
    21     }, false);
    22   }else{
    23     throw new Error("objBlur()没有找到元素");
    24   }
    25   
    26   let docTouchend = function(event){
    27     if(event.target != el){
    28       setTimeout(() => {
    29         el.blur();
    30         document.removeEventListener('touchend', docTouchend, false);
    31       }, time);
    32     }
    33   };
    34 }
    愿你有好运气
      如果没有
        愿你在不幸中学会慈悲
    愿你被很多人爱
      如果没有
        愿你在寂寞中学会宽容
    愿你忠于自己
      活的认真
        笑得放肆
    QQ:218 - 299 - 2121
    Email:sunyutechnogeek@163.com
  • 相关阅读:
    2016第19周三
    2016第19周二
    Android JNI 获取应用程序签名
    HDU 3830 Checkers
    hadoop记录topk
    Codeforces 4A-Watermelon(意甲冠军)
    经验38--新闻内容处理
    Java8高中并发
    ACM-简单的主题Ignatius and the Princess II——hdu1027
    二叉搜索树
  • 原文地址:https://www.cnblogs.com/sunyuweb/p/15223907.html
Copyright © 2011-2022 走看看