Is there a way to make text unselectable on an HTML page? [duplicate]

In most browsers, this can be achieved using CSS: *.unselectable { -moz-user-select: -moz-none; -khtml-user-select: none; -webkit-user-select: none; /* Introduced in IE 10. See http://ie.microsoft.com/testdrive/HTML5/msUserSelect/ */ -ms-user-select: none; user-select: none; } For IE < 10 and Opera, you will need to use the unselectable attribute of the element you wish to be unselectable. You can set … Read more

How to make HTML Text unselectable [duplicate]

You can’t do this with plain vanilla HTML, so JSF can’t do much for you here as well. If you’re targeting decent browsers only, then just make use of CSS3: .unselectable { -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } <label class=”unselectable”>Unselectable label</label> If you’d like to cover older browsers … Read more

Get the Highlighted/Selected text

Getting the text the user has selected is relatively simple. There’s no benefit to be gained by involving jQuery since you need nothing other than the window and document objects. function getSelectionText() { var text = “”; if (window.getSelection) { text = window.getSelection().toString(); } else if (document.selection && document.selection.type != “Control”) { text = document.selection.createRange().text; … Read more