SoFunction
Updated on 2025-04-12

Solve the problem of keyboard occlusion on mobile iOS system

Test ios 9, the ios10 system is valid, please test the others yourself. It is recommended to dynamically introduce this script by judging the system type.

var isIPHONE = ().indexOf("IPHONE")!= -1;
if(isIPHONE){
 // The element loses focus and hides the iPhone's soft keyboard function objBlur(obj,time){
  var startTime=0,endTime=0,
  time = !time?30:time,
  docTouchend = function(event){
   endTime = new Date().getTime();
   if(!= obj && (endTime - startTime <300)){
    setTimeout(function(){
     ();
     ("touchend", docTouchend,false);
    },time);
   }
  };
  ("touchstart",function(){
   startTime = new Date().getTime();
  });
  ("touchend", docTouchend,false);
 }
 $("input").on("focus",function(){
  var id = ;
  var self = this;
  var H = ;
  var pos = getPosition(self);
  if(isIPHONE){
   var input = new objBlur(self);
   input=null;
  }
 });
 function getPosition(target) {
  var left = 0, top = 0;
  do {
   left +=  || 0;
   top +=  || 0;
   target = ;
  } while(target);
  return {
   left: left,
   top: top
  };
 }
}

The above article solves the problem of keyboard occlusion on the mobile iOS system is all the content I share with you. I hope you can give you a reference and I hope you can support me more.