2

I'm trying to build a document editing interface for mobile Safari, and I want to base it on a contentEditable <div>. (Yes, I know this is only available on iOS 5. That's not a problem in my case.)

Editing works fine, but I don't want the user to have to tap the div to start typing. I'd like to begin editing when the page loads.

I've tried multiple approaches, including this one from Stack Overflow. So far, everything I've tried works fine in desktop Safari, but they don't work in mobile Safari.

Ideally, the div would be empty initially, but I'd be okay with having some minimal content in there in the beginning if necessary.

Edit: I may have found the culprit. It seems that focus() doesn't work when called onload, so there may not be a way to do this, even with a <textarea>.

Community
  • 1
  • 1
Ben Wyatt
  • 399
  • 4
  • 14

1 Answers1

0

Try putting the code in a <script> element in the body, below the textarea, instead of using onload.

Mr Lister
  • 45,515
  • 15
  • 108
  • 150