iPhone Mobile Safari: Force keyboard open

后端 未结 5 1833
迷失自我
迷失自我 2021-02-05 00:52

This is an HTML / CSS / JS (jQuery) iPad app. I\'ve got a button, that slides down an input form. I\'d like to focus the user on the input, and then launch the keyboard.

<
5条回答
  •  心在旅途
    2021-02-05 01:42

    Turn that button into an input field then instantly swap focus to the main input field. They keyboard will open and stay opened. Below is an example using a button like you asked, placing a transparent input field over the button the user clicks. Tested on an iPhone 4 (iOS 6/7) and an HTC Windows phone.

    The input you want the user to focus on:

    
    

    The button the user presses (with input field overlayed using css):

    Button
    

    Swap focus instantly:

    function FocusMain()
    {
        $("#main").focus();
    }
    

提交回复
热议问题