Ross Ross - 11 months ago 56
HTML Question

How do I focus an HTML text field on an iPhone (causing the keyboard to come up)?

I'm writing an iPhone web app, and I want to automatically focus a text field when the page is loaded, bringing up the keyboard. The usual Javascript:


doesn't seem to be working. Any ideas?

Answer Source

Note: this answer is old and may not be relevant to newer versions out there...

It comes as no help to you but the last poster in this thread wrote that its a bug of the webkit engine.
I can't tell if its a verified bug or not...

Last post from way back machine (as original seems to not work):

I am developing my app in pure XHTML MP / Ecmascript MP / WCSS. So using native platform browser control api is really not an option for me. Yes the behaviour u mention is the same as mine. I searched his topic in the bugzilla at and found that this indeed is a reported bug. focus() to a text box does highlight the element but does not provide a carat in it for the user to start entering text. Using a timer as mentioned by "" does not help either.

This behaviour is common across platforms (s60,iphone,android) which use the webkit engine.

So as of now i dont see a solution to this problem.

Hope this helps