Why is .disableSelection() deprecated?

You can use CSS to accomplish this in most browsers: http://jsfiddle.net/fQthQ/ * { -ms-user-select: none; /* IE 10+ */ -moz-user-select: -moz-none; -khtml-user-select: none; -webkit-user-select: none; user-select: none; } .selectable { -ms-user-select: auto; -moz-user-select: auto; -khtml-user-select: auto; -webkit-user-select: auto; user-select: auto; } Opera does not currently support this feature. See the MDN page for more info: …

Read more

How to get selected text from a textbox control with JavaScript

OK, here is the code I have: function ShowSelection() { var textComponent = document.getElementById(‘Editor’); var selectedText; if (textComponent.selectionStart !== undefined) { // Standards-compliant version var startPos = textComponent.selectionStart; var endPos = textComponent.selectionEnd; selectedText = textComponent.value.substring(startPos, endPos); } else if (document.selection !== undefined) { // Internet Explorer version textComponent.focus(); var sel = document.selection.createRange(); selectedText = sel.text; …

Read more

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