You can use CSS as follows:
CSS
.unselectable { -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; -o-user-select: none; user-select: none; }
For older versions of IE, the problem is usually more complicated, but you can use the behavior:
CSS
.unselectable { behavior: url(ieUserSelectFix.htc); }
and the behavior file "ieUserSelectFix.htc":
<public:component lightweight="true"> <public:attach event="ondocumentready" onevent="stopSelection()" /> <script type="text/javascript"> <!-- function stopSelection() { element.onselectstart = function() { return(false); }; element.setAttribute('unselectable', 'on', 0); } </script> </public:component>
With Javascript, you can:
yourElement.onselectstart = function() { return(false); };
source share