Kasper Juner
Kasper Juner

Reputation: 952

How to disable text selection on touch press?

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?

Upvotes: 2

Views: 7067

Answers (1)

nano dev
nano dev

Reputation: 443

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; 

Upvotes: 11

Related Questions