1

I have a webpage which should run as a native app in windows so i have to disabled all browser stuff like text selection etc.

I managed to disable the text selection in a normal device like this:

$("body, html").mousedown(function (event) {
  event.preventDefault();
});

But when i run that website in a touch screen device and i long press the text it still select it.

How can i disable the text selection even on touch devices?

Kasper Juner
  • 832
  • 3
  • 15
  • 34

1 Answers1

6

Use this in your CSS..

 -webkit-touch-callout: none; /* Safari */
        -webkit-user-select: none; /* Chrome */     
           -moz-user-select: none; /* Firefox */
            -ms-user-select: none; /* Internet Explorer/Edge */
                user-select: none; 
nano dev
  • 335
  • 4
  • 6
  • This appears to work when added to the css of the body element for iOS Safari 13.7, otherwise it jumps to the nearest selectable element. – bnns Sep 29 '21 at 12:32
  • Works fine for table rows with MUI in react, thanks! – Michael Oct 11 '22 at 10:51