6

I have a mobile app (HTML, Javascript) that is supposed to run on iPhone and Android smartphones. To make it look more like a real app and prevent accidential text selection, I'm cathing the touchStart end touchEnd events and handle them. This prevents text selection just fine. On Android however, it seems to be completely ignored; text selection is possible. Is there a defined way in Android to prevent the user from selecting text from a web app?

René

Krumelur
  • 32,180
  • 27
  • 124
  • 263

1 Answers1

0

You should be able to use WebKit's CSS selector this. Just apply this to "html, body" or your element on the webapp.

-webkit-user-select: none

http://css-infos.net/property/-webkit-user-select

jlindenbaum
  • 1,891
  • 18
  • 28
  • Does not work. Those work on iPhone, but not Android: user-select: none; -webkit-user-select: none; -moz-user-select: none; -khtml-user-select: none; – Krumelur Aug 12 '11 at 18:30
  • Wow - that's baffling. Have you tried a variation of this to get what you want? http://stackoverflow.com/questions/5107651/android-disable-text-selection-in-a-webview – jlindenbaum Aug 12 '11 at 19:02
  • Yes. It causes so many unwanted sideeffects that I don't find it very useful. Android browsers are very weird beasts...even Google's own sites don't really work with them. :-) – Krumelur Aug 12 '11 at 19:38