6

In IE 10, when you click on any text while holding the CTRL key the browser selects the text (which means the text gains focus and I want to avoid this because I have some multi-select scenario where CTRL+click means add/remove-select).

How can I disable this "feature"?

BTW, I still want to be able to select the text using the usual mouse actions.

mtb
  • 1,350
  • 16
  • 32
Jajo
  • 123
  • 1
  • 5
  • 1
    You need to talk to some UI boys. Overriding standard behaviours is something users find confusing and irritating, leaving them with the impression that you couldn't be bothered with them. – Tony Hopkinson Sep 17 '12 at 12:08
  • 2
    I think you comment should be forwarded to the IE10 team... ;) – Jajo Sep 17 '12 at 13:01

2 Answers2

4

This feature can be disabled by disabling selection completely.

This can be done by using -ms-user-select which has been introduced in IE10. (see also: http://ie.microsoft.com/testdrive/HTML5/msUserSelect/Default.html)

Example: To disable selection add the following css class to the element containing the text or one of its parents:

.notselectable
{
    -ms-user-select: none;
}
alex3772
  • 66
  • 2
0

To prevent IE 8 CTRL and SHIFT click text selection on individual element, use this:

var obj = document.createElement("DIV");
obj.onselectstart = function(){
  return false;
}

To prevent text selection on document, use this:

window.onload = function(){
  document.onselectstart = function(){
    return false;
  }
}
mtb
  • 1,350
  • 16
  • 32
rajesh
  • 382
  • 4
  • 5