The mobile keyboard pops up and the web page goes up.

in mobile development, as long as the input gets the focus, the keyboard will pop up to top the page, and the page will still be in the top state when it loses focus. Is there any good way to get him back.


use fixed positioning position: absolute;


call the following method after input initialization

// iosinputfixed
    _fixIosInputH () {
      // ios
      if (!!navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)) {
        let [timeout, beforeTop] = [null, 0]
        $('input, textarea').on('focus', () => {
          beforeTop = document.body.scrollTop
          clearTimeout(timeout)
        }).on('blur', () => {
          timeout = setTimeout(() => {
            document.body.scrollTop = beforeTop
          }, 100)
        })
      }
    }
Menu