I require one HTML element (Label) on my page to be unselectable for IE … currently I have tried
Unselectable=ononselectreturn=false;
none of which is helping me out.
For Firefox and Chrome i have set the following CSS property which are working absolutely fine … but the problem as always with the IE.
CSS properties you have set:
-moz-user-select: -moz-none;
-khtml-user-select: none;
-webkit-user-select: none;
-o-user-select: none;
user-select: none;
is there any alternative or IE-hack?
An answer on Stack Overflow has helped me out but not for IE.
In IE8 there are two ways to make an element unselectable:
1.)
myElement.unselectable = "on"; // Does not work on body elements2.)
myElement.onselectstart = function (){ return false; }Once an element is unselectable, users cannot select from within that element.
However, they are still able to select either the text or the box of the element
by dragging into it from within another element which is not unselectable.
I have tried to work around this by cancelling various events on myElement (ondragenter, oncontrolselect, onmouseenter, onselectionchange…), it didn’t work.
All this applies only to IE8