Search code examples
javascriptandroidandroid-2.3-gingerbread

How to show caret in Android 2.3 in contenteditable div


Currently when I have following HTML code in web page:

<div contenteditable="true">
Some content
</div>

and view it via Android-2.3, I don't see caret.

It exist but is invisible because when I long-press menu button (to force soft keyboard), I can input characters into that div.

So, does anyone know how to force show caret inside that div?


Solution

  • According to this blog post on contenteditable in mobile WebKit, this is a bug in the Android / WebKit source. Considering that it was reported as a bug report in July 2010, it doesn't seem to have a high priority. However, WebKit is open source and you can always consider signing up and fixing the bug yourselves.

    This effectively prevents using editors such as TinyMCE, CKEditor, YahooUI from a mobile device, or at least, you won't be able to see the caret. Sorry that I don't have better news.

    PS: I noticed that it is also not possible to select text in a ContentEditable field, which is a related bug.

    PPS: not sure whether it is possible to use JavaScript to get the caret position. If it is possible, you might be able to mimic the behavior of a caret by drawing a vertical line and let it blink. Maybe this is what Google Docs did to make it working on the Android?