Mobile browser Browse WebApp pop-up keyboard overlay text box solution

Source: Internet
Author: User
Tags tagname

Mobile browser Browse WebApp pop-up keyboard overlay text box solution

Recently encountered Android built-in Browse H5 page, because the text input box (input) placed near the bottom of the page, click on the text box, the input box will be pop-up phone input keyboard cover.

Find a section of the JS code directly resolved, click on the forced scrolling, it seems to solve the same problem under the Android browser browsing.

1 if (/android [4-6]/.test (Navigator.appversion)) {2     window.addeventlistener ("Resize", function () {3         if ( document.activeelement.tagname== "INPUT" | | document.activeelement.tagname== "TEXTAREA") {4             window.settimeout (function () {5                 Document.activeElement.scrollIntoViewIfNeeded (); 6             },0); 7         }8     }) 9}

Add a piece of code: for some pages, because there may be a toolbar at the bottom of the page design (for example, some pages fixed a footer at the bottom), although the system does not need to scroll, but when the input method, The toolbar at the bottom is moving up to cover the input box (common in the case where the input box is exactly in the middle of the page).
You can hide the bottom toolbar by judging the screen height changes.

    <script type= "Text/javascript" >        document.write (' <style> #footer {Visibility:hidden} @media ( Min-height: ' + ($ (window). Height ()-ten) + ' px) {#footer {visibility:visible}}</style> ');    </script>

Mobile browser Browse WebApp pop-up keyboard overlay text box solution

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.