Set the focus of the text box on mobile safari

Hey, I was wondering how to set focus on the text box in Mobile Safari.

I tried document.myForm.myTextArea.focus() , which works in normal Safari, but it does not work in Mobile Safari.

To clarify, I want to focus on the text box as soon as the user loads the page and the iPhone keyboard appears.

+13
iphone mobile mobile-safari
Mar 07 '10 at 23:54
source share
3 answers

Just found this previous post which says this is a bug in webkit. Sorry for not doing a more thorough search.

http://discussion.forum.nokia.com/forum/showthread.php?t=127724

+5
Mar 08 '10 at 0:00
source share

I found a bug report in an iUI project related to this.

It seems that calling focus() will not work if called from the onload or if called via a timer.

http://code.google.com/p/iui/issues/detail?id=129

Update: Although I don’t have a source for this, they tell me (people who tried it) that in iPhone OS 4 the problem with focus() and onload should be fixed.

+4
May 31 '10 at 15:59
source share

Nothing to do with a timer, focus () works at all ... im doing mine through an AJAX function. I think my web application should suffer in mobile safari.

By the way, this also affects HP WebOS devices and any other device that uses mobile safari.

+1
Jun 01 2018-11-11T00:
source share



All Articles