Reputation: 93
The function focus() doenst seem to work for iphone? I need something similar to what they have done for gmail.com when you do a reply.
Upvotes: 1
Views: 1634
Reputation: 122880
If you're targeting iPhone/Android (... and don't have to worry about Windows Phone 7 Phone 7 Phone etc.) you can take advantage of the HTML5 autofocus attribute.
So with some markup like this:
<textarea id="the-textarea" autofocus></textarea>
You get an auto-focused textarea.
If you need to position the caret inside the textarea you can use its setSelectionRange method:
$("#the-textarea")[0].setSelectionRange(0, 0);
Upvotes: 1
Reputation: 5133
If you are only targeting Safari, you might try checking out the Safari-specific documentation: http://developer.apple.com/safari/
Firebug (Firefox extension) can also be very helpful in looking at how other developers are implementing things on their sites.
Upvotes: 0