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
原文地址:https://www.cnblogs.com/sunyuweb/p/15223907.html