After the mobile terminal input box acquired focus, the virtual keyboard bounce, also the bottom of the fixed roof up

var homeFootBar = document.querySelector("底部foot")
var shortcutVal = document.querySelector("input")
shortcutVal.addEventListener("focus", function (e) {
if(navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i)){
focusInput()
}
})

/ * Height of the screen * /
the let docHeight = window.innerHeight //
function focusInput () {
the console.log ( "Andrews phone 2")
window.addEventListener ( 'a resize', function () {
the console.log ( "Andrews phone 3 ", winHeight +" === "+ window.innerHeight)
iF (docHeight> window.innerHeight) {

/ * Android phone when the keyboard pops up when you set the page height is the height of the screen * /
         = homeFootBar.style.display 'none' 
the console.log ( "Andrews bottom of the phone disappear")
document.getElementsByTagName ( 'body') [0] .setAttribute ( 'height', winHeight + 'PX')

} the else {
/ * when the keyboard retracted * /
homeFootBar.style.display = 'Block'

document.getElementsByTagName ( 'body') [0] .setAttribute ( 'height', '100%')

}

})
}

 

Guess you like

Origin www.cnblogs.com/yangwenbo/p/11691318.html