Home > Web Front-end > H5 Tutorial > body text

How to solve the problem of HTML5 virtual keyboard blocking the input box

不言
Release: 2018-07-02 11:41:48
Original
3267 people have browsed it

This article mainly introduces the solution to the problem that the HTML5 virtual keyboard blocks the input box. It has a very good reference value, let’s take a look at it together

Without further ado, please look at the code:

//防止键盘把当前输入框给挡住
$$('input[type="text"],textarea').on('click', function () {
  var target = this;
  setTimeout(function(){
        target.scrollIntoViewIfNeeded();
   },100);
});
Copy after login

Applicable to some Android models.

if(/Android [4-6]/.test(navigator.appVersion)) {
    window.addEventListener("resize", function() {
        if(document.activeElement.tagName=="INPUT" || document.activeElement.tagName=="TEXTAREA") {
            window.setTimeout(function() {
document.activeElement.scrollIntoViewIfNeeded();
            },0);
        }
    })
}
Copy after login

The above is the entire content of this article. I hope it will be helpful to everyone's study. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

HTML5 Plus realizes the function of taking pictures on the mobile APP or selecting pictures to upload in the album

##Using HTML5 Canvas to draw Method of shadow effect

The above is the detailed content of How to solve the problem of HTML5 virtual keyboard blocking the input box. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template