zoukankan      html  css  js  c++  java
  • H5解决安卓软键盘弹出遮蔽的方法

    首先先判断是否为安卓,是的话才添加事件监听,获取焦点元素判断是否为input或者textarea类型,是的话,Element.scrollIntoView() 方法会让当前的元素滚动到浏览器窗口的可视区域内 

      created () {
        var u = navigator.userAgent
        if (u.indexOf('Android') > -1 || u.indexOf('Adr') > -1) {
          this.onFoucs()
        }
      },
      methods: {
        onFoucs () {
          window.addEventListener('resize', function () {
            alert('android')
            if (document.activeElement.tagName === 'INPUT' || document.activeElement.tagName === 'TEXTAREA') {
              alert(document.activeElement.tagName)
              // alert('2332323')
              window.setTimeout(function () {
                alert('scroll')
                document.activeElement.scrollIntoView()
              }, 1)
            }
          })
        }
      },
  • 相关阅读:
    C#取枚举描述
    JSON数组操作
    .NET DES 加密
    MVC返回图片
    with check option
    HashSet<T>类
    Repository模式
    C#泛型集合之Dictionary<k, v>使用技巧
    权限管理——在线列表
    数据库锁
  • 原文地址:https://www.cnblogs.com/chorkiu/p/12200197.html
Copyright © 2011-2022 走看看