zoukankan      html  css  js  c++  java
  • 移动端输入框获取焦点后,虚拟键盘弹起,把固定的底部也顶起来了

    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()
    }
    })

    /*屏幕的高度*/
    let docHeight = window.innerHeight //
    function focusInput() {
    console.log("安卓手机2")
    window.addEventListener('resize', function() {
    console.log("安卓手机3", winHeight +"==="+window.innerHeight)
    if (docHeight> window.innerHeight) {

    /*安卓手机当键盘弹起时设置页面的高度为屏幕的高度*/
             homeFootBar.style.display = 'none'
    console.log("安卓手机底部消失")
    document.getElementsByTagName('body')[0].setAttribute('height', winHeight+'px')

    }else {
    /*当键盘收起时*/
    homeFootBar.style.display = 'block'

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

    }

    })
    }
  • 相关阅读:
    qt学习笔记(1):qt点击运行没有反应。
    JS Object类型
    JS Boolean数据类型和数据类型转换规律
    CSS雪碧图
    CSS
    PS基础
    JS number数字类型
    js中的变量和数据类型
    JS 基础
    单词
  • 原文地址:https://www.cnblogs.com/yangwenbo/p/11691318.html
Copyright © 2011-2022 走看看