I believe it is possible to do this with CSS/JS. Here is something that may work for you:
CSS:
*.unselectable {
-moz-user-select: 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 less than version 10 and Opera browsers, you will need to use the unselectable attribute of the element you wish to be unselectable. You can set this using an attribute in HTML:
...
This property isn't inherited, so you have to put an attribute in the start tag of every element inside the . You could instead use JavaScript to do this recursively for an element's descendants:
function makeUnselectable(node) {
if (node.nodeType == 1) {
node.setAttribute("unselectable", "on");
}
var child = node.firstChild;
while (child) {
makeUnselectable(child);
child = child.nextSibling;
}
}
makeUnselectable(document.getElementById("foo"));
I also found additional methods described here.
I did find out that this method will not work in chrome: "This doesn't have any effect on content loaded as chrome". But, there is a jquery solution that is known to have better compatibility which looks like:
$('textarea')
.attr('unselectable', 'on')
.css('-webkit-user-select', 'none')
.css('-moz-user-select', 'none')
.css("-ms-user-select","none")
.css("-o-user-select","none")
.css("user-select",'none')
.on('selectstart', false)
.on('mousedown', false);
If you still run into issues with being able to select text, you can do a onselect function, unselect.