How to disallow selection of text on website?
It's effectively impossible, assuming some minimal effort on the part of the person who wants the text. All you can really do is create speed bumps that will do nothing but irritate them. Also note that there are perfectly valid uses for the right-click menu (for example) that have nothing to do with stealing your content. If the person is after one of those, then you're really going to be annoying them.
- I can view source via the browser chrome menus.
- I can view source via a key combination.
- I can select large chunks of text by double-clicking on paragraphs.
- I can select all via key combination and edit externally.
- I can fetch the document with wget or similar.
- I can feed the page to a mobilizer (Instapaper, Readability, etc.) then copy the text unrestricted from there.
- I can save to Evernote or similar.
- Besides the numerous workarounds, these tricks tend to be fragile. Some Firefox extension I have–there's nothing installed that targets this sort of thing–is allowing me to right click on that site without issue. The same may be the case for modifications to other browsers.
The list goes on.
If you don't want people copying your text, then don't put it someplace they can get to it.
If, for some reason, all you actually need to do is take some control of the appearance of text being selected, that can be accomplished with the
user-select CSS property (or ::selection though it seems like it's on the way out), but that has no effect on the ability to copy the affected text.