Mobile-compatible processing

Source: Internet
Author: User

First, the previous paragraph to determine the JS code for Android and iOS

Function Navigator () {varU =navigator.useragent; varIsandroid = U.indexof ('Android') >-1|| U.indexof ('ADR') >-1;//Android Terminal        varIsios =!! U.match (/\ (i[^;] +;( U;)? Cpu.+mac OS x/);//iOS terminal        if(isandroid) {// Android        }; if(Isios) {//iOS        }; };navigator ();

iOS FAQs:

1. Search page Search button is not displayed, add form to solve.

<form action="">          <input type="search" name= "id="" value="" /> </form>

2. Remove input shadows and black edges, and type= "search" forks.

css://removes shadows and black input:-webkit-appearance:none; (global input removes shadows and black bottoms, which can be done for an input.) )//Remove small fork input[type= "search"]::-webkit-search-cancel-button{     -webkit-appearance:none;}

iOS: Listening keyboard bounce and pick up:

$ (document). On ("Focusin", function () {            ///Keyboard Popup}) $ (document). On ("Focusout", function () {            //keyboard closed})

iOS: When the head input box is focused, want to bounce the bottom fixed positioning elements, placed above the keyboard, such as footer, or upload a picture of the button or something, but found not up, it's OK I have a solution.

Function Navigator () {var u = navigator.useragent; var isandroid = u.indexof (' Android ') >-1 | | U.indexof (' Adr ') >-1; Android terminal var Isios =!! U.match (/\ (i[^;] +;( U;)? Cpu.+mac OS x/);        iOS terminal if (isandroid) {};                if (Isios) {$ (document). On ("Focusin", function () {////keyboard bounces to the bottom of the scroll bar,                                 $ (window). ScrollTop ($ ("body"). Height ()); Set Timer setTimeout (function () {//Get document height var clien                                         Theight= Document.body.clientHeight;                    Gets the scroll height-that is, the keyboard height var scrolltop = document.body.scrollTop;                    Let you want the bottom of the bottom element: keyboard height.                    $ (". Bottom"). CSS ("bottom", scrolltop+ "px");                                          Finally, set a timer to get the scroll bar back to the top.                                           SetTimeout (function () {    $ (window). scrolltop (0);                },300);            },300);            });                $ (document). On (' Focusout ', function () {//Soft keyboard closed event handling//Let the bottom element return to the bottom.            $ (". Bottom"). CSS ("bottom", "0");        });    }; };Navigator();

Android:

1. Keyboard Pick Up event:

functionNavigator() {var u = navigator.useragent; var isandroid = u.indexof (' Android ') >-1 | | U.indexof (' Adr ') >-1; Android terminal var Isios =!! U.match (/\ (i[^;] +;( U;)? Cpu.+mac OS x/);   iOS terminal if (isandroid) {var wheight = $ (window). Innerheight (); Gets the initial visual window height of $ (window). Resize (function () {//Monitor window size Change event var h     h = $ (window). Innerheight ();   Current visual window height var viewtop = $ (window). scrolltop ();                                               Visual window height top distance from top of page if (Wheight > HH) {//can be used as a virtual keyboard popup event                                                           }else{//Can be used as a virtual keyboard shutdown event                              };                        Wheight = hh;        });        }; if (Isios) {};};Navigator();

Mobile-compatible processing

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.