Unselect text in WebTextArea

Is it possible to unselect the text in a WebTextArea? I can do this in desktop SelectionChange event with

me.SelectionLength = 0

But there does not seem to be the same functionality in web. Do you have any suggestions to do so? My ultimate goal with this is to prevent the user from selecting the text and then copy/paste it. My apps are very content heavy, and I am trying to protect it as much as possible. I know they can type out the content, but I don’t want to make it easy for them to distribute the content to others and online

Keep in mind that regardless of the tricks you try to use, the user can always view the source and copy it from there.


I agree with Greg. There really isn’t much you can do to prevent a determined user.

However I thought of two “hurdles” you can add to your site.

  • Disable right-click with javascript
document.addEventListener('contextmenu', event => event.preventDefault());
  • Disable text selection with CSS
        -webkit-user-select: none;
        -webkit-touch-callout: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
1 Like

Thanks for the tips guys. I’m not overly worried about the determined user. My users are in the field of nutrition, not so much tech-based, so while some may figure a way around copy/paste, the vast majority do not have the skillset. I’m just trying to prevent the ways of making it easy for them. If they cannot select the text as in my desktop app, many of them just say it’s not worth typing all this content out and just use it in the app as it should be used

1 Like