Text is not selectable in IE

I need one HTML element (Label) on my page to be unavailable for IE ... currently I tried

  • Unselectable=on
  • onselectreturn=false;

none of them help me.

For Firefox and Chrome, I set the following CSS property, which works absolutely fine ... but the problem is, as always, with IE.

CSS properties that you set:

-moz-user-select: -moz-none;
-khtml-user-select: none;
-webkit-user-select: none;
-o-user-select: none;
user-select: none;

is there an alternative or IE hack?

The answer to Stack Overflow helped me, but not for IE.

+3
source share
3 answers

There are two ways in IE8 to make an element non-selectable:

1.) myElement.unselectable = "on"; // Does not work on body elements

2.) myElement.onselectstart = function (){ return false; }

, . , , .

, myElement (ondragenter, oncontrolselect, onmouseenter, onselectionchange...), .

IE8

+6

<label unselectable="on"> IE HTML. javascript, setAttribute: labelEl.setAttribute("unselectable","on"). labelEl.unselectable = "on" ( IE9).

, "unselectable" , - , .

+6

Set unselectableto offand it should work.

<label unselectable="off">Something</label>

http://jsfiddle.net/sWguE/1/

It also works for me.

<label onselect="return false">Something</label> 

http://jsfiddle.net/sWguE/3/

0
source

All Articles