[SOLVED] Auto-focus text field in Safari

Answered
0
0

I am creating an InputBox class that is basically a modal form with a single textbox field.  The desired behavior is to automatically give focus to the textbox, and bring up the virtual keyboard on mobile devices. While Chrome automatically selects the text field, I can’t get it to work on Safari. I’ve tried calling .Focus in the form Load() event, but no dice. Any suggestions?

 

Andrew

 

  • You must to post comments
Best Answer
0
0

Thank you. It seems on Safari it is reliant on a user initiated action, and the click to show the form is too far removed: https://stackoverflow.com/questions/6287478/mobile-safari-autofocus-text-field

 

The .focus call is allowed from non-click actions if app is run from homescreen, or if a setting on the webview is set directly.

  • You must to post comments
0
0

Hi Andrew,

 

I have spent many countless hours trying to find a way around this problem but to no avail.  iOS/Safari prevents this behavior, unfortunately.  If I find a way around it, I will let you know.

The closest solution I have found is to create a button and have that trigger the focus event (after clicking).

You can also experiment with JavaScript and using prompts to try to trigger the keyboard.  I’m attaching a screenshot of how to integrate JavaScript with your controls and get return values from them.  I know there is a lot of discussion about this issue on StackOverflow, you can try integrating them this way.

I hope this helps a little bit, it’s a difficult issue!  Please feel free to reach out if you have any other questions.

 

Best,

Levie

Attachment
  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.