1. Determine the Model:
Determine if the phone is mobile or Android
var u = navigator.useragent;
var isandroid = u.indexof (' Android ') >-1 | | U.indexof (' Adr ') >-1; Android Terminal
var Isios =!! U.match (/\ (i[^;] +;( U;)? Cpu.+mac OS x/); iOS terminal
2. Use scroll to solve the absolute position at the bottom of the iOS evoking soft keyboard:
varBfscrolltop = Document.body.scrollTop;//gets the height of the soft keyboard to evoke the scroll portion of the front browser$ (". txt"). Focus (function(){//here ' input.inputframe ' is the input box of my bottom input field, which triggers the event when it gets focusInterval = SetInterval (function(){//set a timer with time settings similar to the time required for the soft keyboard to pop upDocument.body.scrollTop = Document.body.scrollHeight;//assigns all content in the browser to the browser scroll height after getting focus},100)}). blur (function(){//set the event when the input box loses focusClearinterval (interval);//Clear TimerDocument.body.scrollTop = Bfscrolltop;//re-assigns the browser's scroll portion height before the soft keyboard to the changed height }); //Android keyboard Popup processing varclientheight = Document.documentElement.clientHeight | |Document.body.clientHeight; $ (window). On (' Resize ',function () { varNowclientheight = Document.documentElement.clientHeight | |Document.body.clientHeight; if(ClientHeight >nowclientheight) {Console.log ("Android Popup") } Else { $(". Bottom_name"). AddClass ("None")) } });
3. Use the 2 method to solve the problem of the soft keyboard, you need to set the outermost box height:auto;overflow-y:scroll, but if the background with the Lazyload plug-in will require the use of height:auto;overflow-y: Scroll, because it needs to be based on scroll to determine whether the page scrolls, whether the content needs to be loaded.
4. Some events in iOS need double-click to trigger, can be triggered by the following artificial method two times
A.click ();
SetTimeout (function () {
A.click ()
},100)
var bfscrolltop = document.body.scrolltop;//Gets the height of the soft keyboard to evoke the pre-browser scrolling portion of $ (". txt"). focus (function () {//here ' input.inputframe ' Is the input box of my bottom input field, triggering event when it gets focus interval = setinterval (function () {//Set a timer, time setting is similar to the time required to eject the soft keyboard document.body.scrollTo p = document.body.scrollheight;//Gets the focus and assigns all content in the browser to the browser scroll section height},100)}). blur (function () {//Set the event when the input box loses focus CL Earinterval (interval);//Clear Timer Document.body.scrollTop = bfscrolltop;//Re-assign the browser scroll portion height to the changed height before the soft keyboard is aroused});
Android Keyboard popup handling var clientheight = Document.documentElement.clientHeight | | Document.body.clientHeight; $ (window). On (' Resize ', function () {var nowclientheight = Document.documentElement.clientHeight | | document.body.c Lientheight; if (ClientHeight > Nowclientheight) {console.log ("Android Popup")} else {$ (". Bottom_name" ). AddClass ("None")}});
Mobile Side FAQ Summary